forked from VimPlug/jedi
Test module attributes.
This commit is contained in:
@@ -200,16 +200,18 @@ class BaseDefinition(object):
|
|||||||
@property
|
@property
|
||||||
def line(self):
|
def line(self):
|
||||||
"""The line where the definition occurs (starting with 1)."""
|
"""The line where the definition occurs (starting with 1)."""
|
||||||
if self.in_builtin_module():
|
start_pos = self._name.start_pos
|
||||||
|
if start_pos is None:
|
||||||
return None
|
return None
|
||||||
return self._name.start_pos[0]
|
return start_pos[0]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def column(self):
|
def column(self):
|
||||||
"""The column where the definition occurs (starting with 0)."""
|
"""The column where the definition occurs (starting with 0)."""
|
||||||
if self.in_builtin_module():
|
start_pos = self._name.start_pos
|
||||||
|
if start_pos is None:
|
||||||
return None
|
return None
|
||||||
return self._name.start_pos[1]
|
return start_pos[0]
|
||||||
|
|
||||||
def docstring(self, raw=False, fast=True):
|
def docstring(self, raw=False, fast=True):
|
||||||
r"""
|
r"""
|
||||||
@@ -318,8 +320,6 @@ class BaseDefinition(object):
|
|||||||
|
|
||||||
def _goto_definitions(self):
|
def _goto_definitions(self):
|
||||||
# TODO make this function public.
|
# TODO make this function public.
|
||||||
print(self._name.infer(), self._name.parent_context)
|
|
||||||
x = self._name.parent_context
|
|
||||||
return [Definition(self._evaluator, d.name) for d in self._name.infer()]
|
return [Definition(self._evaluator, d.name) for d in self._name.infer()]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
10
test/test_evaluate/test_context.py
Normal file
10
test/test_evaluate/test_context.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from jedi import Script
|
||||||
|
|
||||||
|
|
||||||
|
def test_module_attributes():
|
||||||
|
def_, = Script('__name__').completions()
|
||||||
|
assert def_.name == '__name__'
|
||||||
|
assert def_.line == None
|
||||||
|
assert def_.column == None
|
||||||
|
str_, = def_._goto_definitions()
|
||||||
|
assert str_.name == 'str'
|
||||||
Reference in New Issue
Block a user