Use project instead of sys_path parameter in tests

This commit is contained in:
Dave Halter
2020-01-30 21:02:47 +01:00
parent ceccbf3678
commit 4a1d9a9116
6 changed files with 42 additions and 28 deletions

View File

@@ -129,10 +129,11 @@ def test_completion_docstring(Script, jedi_path):
Jedi should follow imports in certain conditions
"""
def docstr(src, result):
c = Script(src, sys_path=[jedi_path]).complete()[0]
c = Script(src, project=project).complete()[0]
assert c.docstring(raw=True, fast=False) == cleandoc(result)
c = Script('import jedi\njed', sys_path=[jedi_path]).complete()[0]
project = jedi.Project('.', sys_path=[jedi_path])
c = Script('import jedi\njed', project=project).complete()[0]
assert c.docstring(fast=False) == cleandoc(jedi_doc)
docstr('import jedi\njedi.Scr', cleandoc(jedi.Script.__doc__))

View File

@@ -97,9 +97,10 @@ def test_sub_module(Script, jedi_path):
path.
"""
sys_path = [jedi_path]
defs = Script('from jedi.api import classes; classes', sys_path=sys_path).infer()
project = jedi.Project('.', sys_path=sys_path)
defs = Script('from jedi.api import classes; classes', project=project).infer()
assert [d.full_name for d in defs] == ['jedi.api.classes']
defs = Script('import jedi.api; jedi.api', sys_path=sys_path).infer()
defs = Script('import jedi.api; jedi.api', project=project).infer()
assert [d.full_name for d in defs] == ['jedi.api']

View File

@@ -3,6 +3,7 @@
All character set and unicode related tests.
"""
from jedi._compatibility import u, unicode
from jedi import Project
def test_unicode_script(Script):
@@ -70,7 +71,8 @@ def test_wrong_encoding(Script, tmpdir):
# Use both latin-1 and utf-8 (a really broken file).
x.write_binary(u'foobar = 1\nä'.encode('latin-1') + u'ä'.encode('utf-8'))
c, = Script('import x; x.foo', sys_path=[tmpdir.strpath]).complete()
project = Project('.', sys_path=[tmpdir.strpath])
c, = Script('import x; x.foo', project=project).complete()
assert c.name == 'foobar'