mirror of
https://github.com/davidhalter/jedi.git
synced 2026-03-05 05:44:15 +08:00
Merge branch 'project'
This commit is contained in:
@@ -2,10 +2,11 @@
|
||||
Tests ``from __future__ import absolute_import`` (only important for
|
||||
Python 2.X)
|
||||
"""
|
||||
from jedi import Project
|
||||
from .. import helpers
|
||||
|
||||
|
||||
@helpers.cwd_at("test/examples/absolute_import")
|
||||
def test_can_complete_when_shadowing(Script):
|
||||
script = Script(path="unittest.py")
|
||||
path = helpers.get_example_dir('absolute_import', 'unittest.py')
|
||||
script = Script(path=path, project=Project(helpers.get_example_dir('absolute_import')))
|
||||
assert script.complete()
|
||||
|
||||
@@ -5,7 +5,7 @@ from jedi._compatibility import force_unicode
|
||||
from jedi.inference.sys_path import _get_parent_dir_with_file, \
|
||||
_get_buildout_script_paths, check_sys_path_modifications
|
||||
|
||||
from ..helpers import cwd_at
|
||||
from ..helpers import get_example_dir
|
||||
|
||||
|
||||
def check_module_test(Script, code):
|
||||
@@ -13,20 +13,18 @@ def check_module_test(Script, code):
|
||||
return check_sys_path_modifications(module_context)
|
||||
|
||||
|
||||
@cwd_at('test/examples/buildout_project/src/proj_name')
|
||||
def test_parent_dir_with_file(Script):
|
||||
parent = _get_parent_dir_with_file(
|
||||
os.path.abspath(os.curdir), 'buildout.cfg')
|
||||
path = get_example_dir('buildout_project', 'src', 'proj_name')
|
||||
parent = _get_parent_dir_with_file(path, 'buildout.cfg')
|
||||
assert parent is not None
|
||||
assert parent.endswith(os.path.join('test', 'examples', 'buildout_project'))
|
||||
|
||||
|
||||
@cwd_at('test/examples/buildout_project/src/proj_name')
|
||||
def test_buildout_detection(Script):
|
||||
scripts = list(_get_buildout_script_paths(os.path.abspath('./module_name.py')))
|
||||
path = get_example_dir('buildout_project', 'src', 'proj_name')
|
||||
scripts = list(_get_buildout_script_paths(os.path.join(path, 'module_name.py')))
|
||||
assert len(scripts) == 1
|
||||
curdir = os.path.abspath(os.curdir)
|
||||
appdir_path = os.path.normpath(os.path.join(curdir, '../../bin/app'))
|
||||
appdir_path = os.path.normpath(os.path.join(path, '../../bin/app'))
|
||||
assert scripts[0] == appdir_path
|
||||
|
||||
|
||||
@@ -53,13 +51,12 @@ def test_path_from_invalid_sys_path_assignment(Script):
|
||||
assert 'invalid' not in paths
|
||||
|
||||
|
||||
@cwd_at('test/examples/buildout_project/src/proj_name/')
|
||||
def test_sys_path_with_modifications(Script):
|
||||
path = get_example_dir('buildout_project', 'src', 'proj_name', 'module_name.py')
|
||||
code = dedent("""
|
||||
import os
|
||||
""")
|
||||
|
||||
path = os.path.abspath(os.path.join(os.curdir, 'module_name.py'))
|
||||
paths = Script(code, path=path)._inference_state.get_sys_path()
|
||||
assert '/tmp/.buildout/eggs/important_package.egg' in paths
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ Test compiled module
|
||||
import os
|
||||
|
||||
import jedi
|
||||
from ..helpers import cwd_at
|
||||
from ..helpers import get_example_dir
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ def test_get_signatures_stdlib(Script):
|
||||
|
||||
|
||||
# Check only on linux 64 bit platform and Python3.4.
|
||||
@pytest.mark.parametrize('load_unsafe_extensions', [False, True])
|
||||
@pytest.mark.skipif('sys.platform != "linux" or sys.maxsize <= 2**32 or sys.version_info[:2] != (3, 4)')
|
||||
@cwd_at('test/examples')
|
||||
def test_init_extension_module(Script):
|
||||
def test_init_extension_module(Script, load_unsafe_extensions):
|
||||
"""
|
||||
``__init__`` extension modules are also packages and Jedi should understand
|
||||
that.
|
||||
@@ -50,8 +50,26 @@ def test_init_extension_module(Script):
|
||||
|
||||
This is also why this test only runs on certain systems (and Python 3.4).
|
||||
"""
|
||||
s = jedi.Script('import init_extension_module as i\ni.', path='not_existing.py')
|
||||
assert 'foo' in [c.name for c in s.complete()]
|
||||
|
||||
s = jedi.Script('from init_extension_module import foo\nfoo', path='not_existing.py')
|
||||
assert ['foo'] == [c.name for c in s.complete()]
|
||||
project = jedi.Project(get_example_dir(), load_unsafe_extensions=load_unsafe_extensions)
|
||||
s = jedi.Script(
|
||||
'import init_extension_module as i\ni.',
|
||||
path='not_existing.py',
|
||||
project=project,
|
||||
)
|
||||
if load_unsafe_extensions:
|
||||
assert 'foo' in [c.name for c in s.complete()]
|
||||
else:
|
||||
assert 'foo' not in [c.name for c in s.complete()]
|
||||
|
||||
s = jedi.Script(
|
||||
'from init_extension_module import foo\nfoo',
|
||||
path='not_existing.py',
|
||||
project=project,
|
||||
)
|
||||
c, = s.complete()
|
||||
assert c.name == 'foo'
|
||||
if load_unsafe_extensions:
|
||||
assert c.infer()
|
||||
else:
|
||||
assert not c.infer()
|
||||
|
||||
@@ -28,10 +28,10 @@ def test_sqlite3_conversion(Script):
|
||||
def test_conversion_of_stub_only(Script):
|
||||
project = Project(os.path.join(root_dir, 'test', 'completion', 'stub_folder'))
|
||||
code = 'import stub_only; stub_only.in_stub_only'
|
||||
d1, = Script(code, _project=project).goto()
|
||||
d1, = Script(code, project=project).goto()
|
||||
assert d1.is_stub()
|
||||
|
||||
script = Script(path=d1.module_path, _project=project)
|
||||
script = Script(path=d1.module_path, project=project)
|
||||
d2, = script.goto(line=d1.line, column=d1.column)
|
||||
assert d2.is_stub()
|
||||
assert d2.module_path == d1.module_path
|
||||
@@ -42,7 +42,7 @@ def test_conversion_of_stub_only(Script):
|
||||
|
||||
def test_goto_on_file(Script):
|
||||
project = Project(os.path.join(root_dir, 'test', 'completion', 'stub_folder'))
|
||||
script = Script('import stub_only; stub_only.Foo', _project=project)
|
||||
script = Script('import stub_only; stub_only.Foo', project=project)
|
||||
d1, = script.goto()
|
||||
v, = d1._name.infer()
|
||||
foo, bar, obj = v.py__mro__()
|
||||
@@ -51,7 +51,7 @@ def test_goto_on_file(Script):
|
||||
assert obj.py__name__() == 'object'
|
||||
|
||||
# Make sure we go to Bar, because Foo is a bit before: `class Foo(Bar):`
|
||||
script = Script(path=d1.module_path, _project=project)
|
||||
script = Script(path=d1.module_path, project=project)
|
||||
d2, = script.goto(line=d1.line, column=d1.column + 4)
|
||||
assert d2.name == 'Bar'
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import pytest
|
||||
def ScriptInStubFolder(Script):
|
||||
path = get_example_dir('stub_packages')
|
||||
project = Project(path, sys_path=[path], smart_sys_path=False)
|
||||
return partial(Script, _project=project)
|
||||
return partial(Script, project=project)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -54,7 +54,7 @@ def test_infer_and_goto(Script, code, full_name, has_stub, has_python, way,
|
||||
has_python = False
|
||||
|
||||
project = Project(os.path.join(root_dir, 'test', 'completion', 'stub_folder'))
|
||||
s = Script(code, _project=project)
|
||||
s = Script(code, project=project)
|
||||
prefer_stubs = kwargs['prefer_stubs']
|
||||
only_stubs = kwargs['only_stubs']
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ from os.path import dirname
|
||||
import pytest
|
||||
|
||||
from test.helpers import get_example_dir, example_dir
|
||||
from jedi import Project
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
@@ -14,9 +15,10 @@ def skip_not_supported_versions(environment):
|
||||
def test_implicit_namespace_package(Script):
|
||||
sys_path = [get_example_dir('implicit_namespace_package', 'ns1'),
|
||||
get_example_dir('implicit_namespace_package', 'ns2')]
|
||||
project = Project('.', sys_path=sys_path)
|
||||
|
||||
def script_with_path(*args, **kwargs):
|
||||
return Script(sys_path=sys_path, *args, **kwargs)
|
||||
return Script(project=project, *args, **kwargs)
|
||||
|
||||
# goto definition
|
||||
assert script_with_path('from pkg import ns1_file').infer()
|
||||
@@ -55,15 +57,14 @@ def test_implicit_namespace_package(Script):
|
||||
def test_implicit_nested_namespace_package(Script):
|
||||
code = 'from implicit_nested_namespaces.namespace.pkg.module import CONST'
|
||||
|
||||
sys_path = [example_dir]
|
||||
|
||||
script = Script(sys_path=sys_path, source=code, line=1, column=61)
|
||||
project = Project('.', sys_path=[example_dir])
|
||||
script = Script(project=project, source=code, line=1, column=61)
|
||||
|
||||
result = script.infer()
|
||||
|
||||
assert len(result) == 1
|
||||
|
||||
implicit_pkg, = Script(code, sys_path=sys_path).infer(column=10)
|
||||
implicit_pkg, = Script(code, project=project).infer(column=10)
|
||||
assert implicit_pkg.type == 'module'
|
||||
assert implicit_pkg.module_path is None
|
||||
|
||||
@@ -71,9 +72,8 @@ def test_implicit_nested_namespace_package(Script):
|
||||
def test_implicit_namespace_package_import_autocomplete(Script):
|
||||
CODE = 'from implicit_name'
|
||||
|
||||
sys_path = [example_dir]
|
||||
|
||||
script = Script(sys_path=sys_path, source=CODE)
|
||||
project = Project('.', sys_path=[example_dir])
|
||||
script = Script(project=project, source=CODE)
|
||||
compl = script.complete()
|
||||
assert [c.name for c in compl] == ['implicit_namespace_package']
|
||||
|
||||
@@ -83,7 +83,8 @@ def test_namespace_package_in_multiple_directories_autocompletion(Script):
|
||||
sys_path = [get_example_dir('implicit_namespace_package', 'ns1'),
|
||||
get_example_dir('implicit_namespace_package', 'ns2')]
|
||||
|
||||
script = Script(sys_path=sys_path, source=CODE)
|
||||
project = Project('.', sys_path=sys_path)
|
||||
script = Script(project=project, source=CODE)
|
||||
compl = script.complete()
|
||||
assert set(c.name for c in compl) == set(['ns1_file', 'ns2_file'])
|
||||
|
||||
@@ -92,7 +93,8 @@ def test_namespace_package_in_multiple_directories_goto_definition(Script):
|
||||
CODE = 'from pkg import ns1_file'
|
||||
sys_path = [get_example_dir('implicit_namespace_package', 'ns1'),
|
||||
get_example_dir('implicit_namespace_package', 'ns2')]
|
||||
script = Script(sys_path=sys_path, source=CODE)
|
||||
project = Project('.', sys_path=sys_path)
|
||||
script = Script(project=project, source=CODE)
|
||||
result = script.infer()
|
||||
assert len(result) == 1
|
||||
|
||||
@@ -102,6 +104,7 @@ def test_namespace_name_autocompletion_full_name(Script):
|
||||
sys_path = [get_example_dir('implicit_namespace_package', 'ns1'),
|
||||
get_example_dir('implicit_namespace_package', 'ns2')]
|
||||
|
||||
script = Script(sys_path=sys_path, source=CODE)
|
||||
project = Project('.', sys_path=sys_path)
|
||||
script = Script(project=project, source=CODE)
|
||||
compl = script.complete()
|
||||
assert set(c.full_name for c in compl) == set(['pkg'])
|
||||
|
||||
@@ -6,15 +6,15 @@ Tests".
|
||||
import os
|
||||
|
||||
import pytest
|
||||
from jedi.file_io import FileIO, KnownContentFileIO
|
||||
|
||||
from jedi.file_io import FileIO, KnownContentFileIO
|
||||
from jedi._compatibility import find_module_py33, find_module
|
||||
from jedi.inference import compiled
|
||||
from jedi.inference import imports
|
||||
from jedi.api.project import Project
|
||||
from jedi.inference.gradual.conversion import _stub_to_python_value_set
|
||||
from jedi.inference.references import get_module_contexts_containing_name
|
||||
from ..helpers import cwd_at, get_example_dir, test_dir, root_dir
|
||||
from ..helpers import get_example_dir, test_dir, test_dir_project, root_dir
|
||||
|
||||
THIS_DIR = os.path.dirname(__file__)
|
||||
|
||||
@@ -44,7 +44,9 @@ pkg_zip_path = get_example_dir('zipped_imports', 'pkg.zip')
|
||||
|
||||
def test_find_module_package_zipped(Script, inference_state, environment):
|
||||
sys_path = environment.get_sys_path() + [pkg_zip_path]
|
||||
script = Script('import pkg; pkg.mod', sys_path=sys_path)
|
||||
|
||||
project = Project('.', sys_path=sys_path)
|
||||
script = Script('import pkg; pkg.mod', project=project)
|
||||
assert len(script.complete()) == 1
|
||||
|
||||
file_io, is_package = inference_state.compiled_subprocess.get_module_info(
|
||||
@@ -86,7 +88,7 @@ def test_find_module_package_zipped(Script, inference_state, environment):
|
||||
def test_correct_zip_package_behavior(Script, inference_state, environment, code,
|
||||
file, package, path, skip_python2):
|
||||
sys_path = environment.get_sys_path() + [pkg_zip_path]
|
||||
pkg, = Script(code, sys_path=sys_path).infer()
|
||||
pkg, = Script(code, project=Project('.', sys_path=sys_path)).infer()
|
||||
value, = pkg._name.infer()
|
||||
assert value.py__file__() == os.path.join(pkg_zip_path, 'pkg', file)
|
||||
assert '.'.join(value.py__package__()) == package
|
||||
@@ -98,7 +100,7 @@ def test_correct_zip_package_behavior(Script, inference_state, environment, code
|
||||
def test_find_module_not_package_zipped(Script, inference_state, environment):
|
||||
path = get_example_dir('zipped_imports', 'not_pkg.zip')
|
||||
sys_path = environment.get_sys_path() + [path]
|
||||
script = Script('import not_pkg; not_pkg.val', sys_path=sys_path)
|
||||
script = Script('import not_pkg; not_pkg.val', project=Project('.', sys_path=sys_path))
|
||||
assert len(script.complete()) == 1
|
||||
|
||||
file_io, is_package = inference_state.compiled_subprocess.get_module_info(
|
||||
@@ -110,19 +112,24 @@ def test_find_module_not_package_zipped(Script, inference_state, environment):
|
||||
assert is_package is False
|
||||
|
||||
|
||||
@cwd_at('test/examples/not_in_sys_path/pkg')
|
||||
def test_import_not_in_sys_path(Script):
|
||||
def test_import_not_in_sys_path(Script, environment):
|
||||
"""
|
||||
non-direct imports (not in sys.path)
|
||||
|
||||
This is in the end just a fallback.
|
||||
"""
|
||||
a = Script(path='module.py').infer(line=5)
|
||||
path = get_example_dir()
|
||||
module_path = os.path.join(path, 'not_in_sys_path', 'pkg', 'module.py')
|
||||
# This project tests the smart path option of Project. The sys_path is
|
||||
# explicitly given to make sure that the path is just dumb and only
|
||||
# includes non-folder dependencies.
|
||||
project = Project(path, sys_path=environment.get_sys_path())
|
||||
a = Script(path=module_path, project=project).infer(line=5)
|
||||
assert a[0].name == 'int'
|
||||
|
||||
a = Script(path='module.py').infer(line=6)
|
||||
a = Script(path=module_path, project=project).infer(line=6)
|
||||
assert a[0].name == 'str'
|
||||
a = Script(path='module.py').infer(line=7)
|
||||
a = Script(path=module_path, project=project).infer(line=7)
|
||||
assert a[0].name == 'str'
|
||||
|
||||
|
||||
@@ -144,14 +151,13 @@ def test_flask_ext(Script, code, name):
|
||||
"""flask.ext.foo is really imported from flaskext.foo or flask_foo.
|
||||
"""
|
||||
path = get_example_dir('flask-site-packages')
|
||||
completions = Script(code, sys_path=[path]).complete()
|
||||
completions = Script(code, project=Project('.', sys_path=[path])).complete()
|
||||
assert name in [c.name for c in completions]
|
||||
|
||||
|
||||
@cwd_at('test/test_inference/')
|
||||
def test_not_importable_file(Script):
|
||||
src = 'import not_importable_file as x; x.'
|
||||
assert not Script(src, path='example.py').complete()
|
||||
assert not Script(src, path='example.py', project=test_dir_project).complete()
|
||||
|
||||
|
||||
def test_import_unique(Script):
|
||||
@@ -166,10 +172,14 @@ def test_cache_works_with_sys_path_param(Script, tmpdir):
|
||||
bar_path = tmpdir.join('bar')
|
||||
foo_path.join('module.py').write('foo = 123', ensure=True)
|
||||
bar_path.join('module.py').write('bar = 123', ensure=True)
|
||||
foo_completions = Script('import module; module.',
|
||||
sys_path=[foo_path.strpath]).complete()
|
||||
bar_completions = Script('import module; module.',
|
||||
sys_path=[bar_path.strpath]).complete()
|
||||
foo_completions = Script(
|
||||
'import module; module.',
|
||||
project=Project('.', sys_path=[foo_path.strpath]),
|
||||
).complete()
|
||||
bar_completions = Script(
|
||||
'import module; module.',
|
||||
project=Project('.', sys_path=[bar_path.strpath]),
|
||||
).complete()
|
||||
assert 'foo' in [c.name for c in foo_completions]
|
||||
assert 'bar' not in [c.name for c in foo_completions]
|
||||
|
||||
@@ -194,29 +204,29 @@ def test_goto_definition_on_import(Script):
|
||||
assert len(Script("import sys").infer(1, 8)) == 1
|
||||
|
||||
|
||||
@cwd_at('jedi')
|
||||
def test_complete_on_empty_import(Script):
|
||||
assert Script("from datetime import").complete()[0].name == 'import'
|
||||
def test_complete_on_empty_import(ScriptWithProject):
|
||||
path = os.path.join(test_dir, 'whatever.py')
|
||||
assert ScriptWithProject("from datetime import").complete()[0].name == 'import'
|
||||
# should just list the files in the directory
|
||||
assert 10 < len(Script("from .", path='whatever.py').complete()) < 30
|
||||
assert 10 < len(ScriptWithProject("from .", path=path).complete()) < 30
|
||||
|
||||
# Global import
|
||||
assert len(Script("from . import", 'whatever.py').complete(1, 5)) > 30
|
||||
assert len(ScriptWithProject("from . import", path=path).complete(1, 5)) > 30
|
||||
# relative import
|
||||
assert 10 < len(Script("from . import", 'whatever.py').complete(1, 6)) < 30
|
||||
assert 10 < len(ScriptWithProject("from . import", path=path).complete(1, 6)) < 30
|
||||
|
||||
# Global import
|
||||
assert len(Script("from . import classes", 'whatever.py').complete(1, 5)) > 30
|
||||
assert len(ScriptWithProject("from . import classes", path=path).complete(1, 5)) > 30
|
||||
# relative import
|
||||
assert 10 < len(Script("from . import classes", 'whatever.py').complete(1, 6)) < 30
|
||||
assert 10 < len(ScriptWithProject("from . import classes", path=path).complete(1, 6)) < 30
|
||||
|
||||
wanted = {'ImportError', 'import', 'ImportWarning'}
|
||||
assert {c.name for c in Script("import").complete()} == wanted
|
||||
assert len(Script("import import", path='').complete()) > 0
|
||||
assert {c.name for c in ScriptWithProject("import").complete()} == wanted
|
||||
assert len(ScriptWithProject("import import", path=path).complete()) > 0
|
||||
|
||||
# 111
|
||||
assert Script("from datetime import").complete()[0].name == 'import'
|
||||
assert Script("from datetime import ").complete()
|
||||
assert ScriptWithProject("from datetime import").complete()[0].name == 'import'
|
||||
assert ScriptWithProject("from datetime import ").complete()
|
||||
|
||||
|
||||
def test_imports_on_global_namespace_without_path(Script):
|
||||
@@ -363,7 +373,7 @@ def test_relative_imports_with_multiple_similar_directories(Script, path, empty_
|
||||
script = Script(
|
||||
"from . ",
|
||||
path=os.path.join(dir, path),
|
||||
_project=project,
|
||||
project=project,
|
||||
)
|
||||
name, import_ = script.complete()
|
||||
assert import_.name == 'import'
|
||||
@@ -376,28 +386,28 @@ def test_relative_imports_with_outside_paths(Script):
|
||||
script = Script(
|
||||
"from ...",
|
||||
path=os.path.join(dir, 'api/whatever/test_this.py'),
|
||||
_project=project,
|
||||
project=project,
|
||||
)
|
||||
assert [c.name for c in script.complete()] == ['api', 'whatever']
|
||||
|
||||
script = Script(
|
||||
"from " + '.' * 100,
|
||||
path=os.path.join(dir, 'api/whatever/test_this.py'),
|
||||
_project=project,
|
||||
project=project,
|
||||
)
|
||||
assert not script.complete()
|
||||
|
||||
|
||||
@cwd_at('test/examples/issue1209/api/whatever/')
|
||||
def test_relative_imports_without_path(Script):
|
||||
project = Project('.', sys_path=[], smart_sys_path=False)
|
||||
script = Script("from . ", _project=project)
|
||||
path = get_example_dir('issue1209', 'api', 'whatever')
|
||||
project = Project(path, sys_path=[], smart_sys_path=False)
|
||||
script = Script("from . ", project=project)
|
||||
assert [c.name for c in script.complete()] == ['api_test1', 'import']
|
||||
|
||||
script = Script("from .. ", _project=project)
|
||||
script = Script("from .. ", project=project)
|
||||
assert [c.name for c in script.complete()] == ['import', 'whatever']
|
||||
|
||||
script = Script("from ... ", _project=project)
|
||||
script = Script("from ... ", project=project)
|
||||
assert [c.name for c in script.complete()] == ['api', 'import', 'whatever']
|
||||
|
||||
|
||||
@@ -460,7 +470,7 @@ def test_import_needed_modules_by_jedi(Script, environment, tmpdir, name):
|
||||
script = Script(
|
||||
'import ' + name,
|
||||
path=tmpdir.join('something.py').strpath,
|
||||
sys_path=[tmpdir.strpath] + environment.get_sys_path(),
|
||||
project=Project('.', sys_path=[tmpdir.strpath] + environment.get_sys_path()),
|
||||
)
|
||||
module, = script.infer()
|
||||
assert module._inference_state.builtins_module.py__file__() != module_path
|
||||
|
||||
@@ -4,6 +4,7 @@ import pytest
|
||||
import py
|
||||
|
||||
from ..helpers import get_example_dir, example_dir
|
||||
from jedi import Project
|
||||
|
||||
|
||||
SYS_PATH = [get_example_dir('namespace_package', 'ns1'),
|
||||
@@ -11,7 +12,7 @@ SYS_PATH = [get_example_dir('namespace_package', 'ns1'),
|
||||
|
||||
|
||||
def script_with_path(Script, *args, **kwargs):
|
||||
return Script(sys_path=SYS_PATH, *args, **kwargs)
|
||||
return Script(project=Project('.', sys_path=SYS_PATH), *args, **kwargs)
|
||||
|
||||
|
||||
def test_goto_definition(Script):
|
||||
@@ -69,8 +70,8 @@ def test_nested_namespace_package(Script):
|
||||
code = 'from nested_namespaces.namespace.pkg import CONST'
|
||||
|
||||
sys_path = [example_dir]
|
||||
|
||||
script = Script(sys_path=sys_path, source=code)
|
||||
project = Project('.', sys_path=sys_path)
|
||||
script = Script(project=project, source=code)
|
||||
|
||||
result = script.infer(line=1, column=45)
|
||||
|
||||
|
||||
@@ -55,7 +55,8 @@ def pyc_project_path(tmpdir):
|
||||
shutil.rmtree(path)
|
||||
|
||||
|
||||
def test_pyc(pyc_project_path, environment):
|
||||
@pytest.mark.parametrize('load_unsafe_extensions', [False, True])
|
||||
def test_pyc(pyc_project_path, environment, load_unsafe_extensions):
|
||||
"""
|
||||
The list of completion must be greater than 2.
|
||||
"""
|
||||
@@ -66,8 +67,14 @@ def test_pyc(pyc_project_path, environment):
|
||||
# we also have the same version and it's easier to debug.
|
||||
environment = SameEnvironment()
|
||||
environment = environment
|
||||
project = jedi.Project(pyc_project_path, load_unsafe_extensions=load_unsafe_extensions)
|
||||
s = jedi.Script(
|
||||
"from dummy_package import dummy; dummy.",
|
||||
path=path,
|
||||
environment=environment)
|
||||
assert len(s.complete()) >= 2
|
||||
environment=environment,
|
||||
project=project,
|
||||
)
|
||||
if load_unsafe_extensions:
|
||||
assert len(s.complete()) >= 2
|
||||
else:
|
||||
assert not s.complete()
|
||||
|
||||
Reference in New Issue
Block a user