forked from VimPlug/jedi
Proper loading for third-party stub packages
This commit is contained in:
1
test/examples/stub_packages/no_python-stubs/__init__.pyi
Normal file
1
test/examples/stub_packages/no_python-stubs/__init__.pyi
Normal file
@@ -0,0 +1 @@
|
||||
foo: int
|
||||
@@ -0,0 +1,2 @@
|
||||
both: int
|
||||
stub_only: str
|
||||
1
test/examples/stub_packages/with_python-stubs/module.pyi
Normal file
1
test/examples/stub_packages/with_python-stubs/module.pyi
Normal file
@@ -0,0 +1 @@
|
||||
in_sub_module: int
|
||||
2
test/examples/stub_packages/with_python/__init__.py
Normal file
2
test/examples/stub_packages/with_python/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
python_only = 1
|
||||
both = ''
|
||||
1
test/examples/stub_packages/with_python/module.py
Normal file
1
test/examples/stub_packages/with_python/module.py
Normal file
@@ -0,0 +1 @@
|
||||
in_sub_module = ''
|
||||
27
test/test_evaluate/test_gradual/test_stub_loading.py
Normal file
27
test/test_evaluate/test_gradual/test_stub_loading.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from functools import partial
|
||||
from test.helpers import get_example_dir
|
||||
from jedi.api.project import Project
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ScriptInStubFolder(Script):
|
||||
path = get_example_dir('stub_packages')
|
||||
project = Project(path, sys_path=[path], smart_sys_path=False)
|
||||
return partial(Script, _project=project)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
('code', 'expected'), [
|
||||
('from no_python import foo', ['int']),
|
||||
('from with_python import stub_only', ['str']),
|
||||
('from with_python import python_only', []),
|
||||
('from with_python import both', ['int']),
|
||||
('from with_python import something_random', []),
|
||||
('from with_python.module import in_sub_module', ['int']),
|
||||
]
|
||||
)
|
||||
def test_find_stubs_infer(ScriptInStubFolder, code, expected):
|
||||
defs = ScriptInStubFolder(code).goto_definitions()
|
||||
assert [d.name for d in defs] == expected
|
||||
Reference in New Issue
Block a user