Get rid of follow_definition and replace it with infer

This commit is contained in:
Dave Halter
2019-05-31 00:35:18 +02:00
parent 9a713bc36f
commit f7076da700
2 changed files with 12 additions and 30 deletions

View File

@@ -7,14 +7,14 @@ from ..helpers import cwd_at
def test_import_empty(Script):
""" github #340, return the full word. """
completion = Script("import ").completions()[0]
definition = completion.follow_definition()[0]
definition = completion.infer()[0]
assert definition
def check_follow_definition_types(Script, source):
# nested import
completions = Script(source, path='some_path.py').completions()
defs = chain.from_iterable(c.follow_definition() for c in completions)
defs = chain.from_iterable(c.infer() for c in completions)
return [d.type for d in defs]
@@ -30,7 +30,7 @@ def test_follow_import_incomplete(Script, environment):
itert = jedi.Script("from itertools import ").completions()
definitions = [d for d in itert if d.name == 'chain']
assert len(definitions) == 1
assert [d.type for d in definitions[0].follow_definition()] == ['class']
assert [d.type for d in definitions[0].infer()] == ['class']
# incomplete `from * import` part
datetime = check_follow_definition_types(Script, "from datetime import datetim")
@@ -40,7 +40,7 @@ def test_follow_import_incomplete(Script, environment):
assert set(datetime) == {'class', 'instance'} # py3: builtin and pure py version
# os.path check
ospath = check_follow_definition_types(Script, "from os.path import abspat")
assert ospath == ['function']
assert set(ospath) == {'function'}
# alias
alias = check_follow_definition_types(Script, "import io as abcd; abcd")