1
0
forked from VimPlug/jedi

Test module attributes.

This commit is contained in:
Dave Halter
2017-01-04 18:32:16 +01:00
parent 0caeef2589
commit 55ec47f15f
2 changed files with 16 additions and 6 deletions

View File

@@ -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

View 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'