diff --git a/jedi/api/classes.py b/jedi/api/classes.py index 0138f618..2e0ce13d 100644 --- a/jedi/api/classes.py +++ b/jedi/api/classes.py @@ -173,10 +173,8 @@ class BaseDefinition(object): par = self._definition while par is not None: if isinstance(par, pr.Import): - path += par.from_names - path += par.namespace_names - if par.relative_count == 0: - break + path += imports.ImportWrapper(self._evaluator, self._name).import_path + break with common.ignored(AttributeError): path.insert(0, par.name) par = par.parent diff --git a/test/test_api/test_full_name.py b/test/test_api/test_full_name.py index 9d1566d8..f54d771e 100644 --- a/test/test_api/test_full_name.py +++ b/test/test_api/test_full_name.py @@ -27,16 +27,14 @@ class MixinTestFullName(object): def check(self, source, desired): script = jedi.Script(textwrap.dedent(source)) definitions = getattr(script, type(self).operation)() + assert len(definitions) == 1 self.assertEqual(definitions[0].full_name, desired) def test_os_path_join(self): self.check('import os; os.path.join', 'os.path.join') def test_builtin(self): - self.check('type', 'type') - - def test_from_import(self): - self.check('from os import path', 'os.path') + self.check('TypeError', 'TypeError') class TestFullNameWithGotoDefinitions(MixinTestFullName, TestCase): @@ -49,6 +47,9 @@ class TestFullNameWithGotoDefinitions(MixinTestFullName, TestCase): any_re = re.compile('.*') any_re""", 're.RegexObject') + def test_from_import(self): + self.check('from os import path', 'os.path') + class TestFullNameWithCompletions(MixinTestFullName, TestCase): operation = 'completions'