mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Write a test for #1209
Relative imports were failing in nested Python packages. With the fix to transforming paths to dotted paths this should already be a lot better, still here's a regression test.
This commit is contained in:
0
test/examples/issue1209/__init__.py
Normal file
0
test/examples/issue1209/__init__.py
Normal file
0
test/examples/issue1209/api/__init__.py
Normal file
0
test/examples/issue1209/api/__init__.py
Normal file
0
test/examples/issue1209/api/whatever/__init__.py
Normal file
0
test/examples/issue1209/api/whatever/__init__.py
Normal file
0
test/examples/issue1209/api/whatever/api_test1.py
Normal file
0
test/examples/issue1209/api/whatever/api_test1.py
Normal file
0
test/examples/issue1209/whatever/__init__.py
Normal file
0
test/examples/issue1209/whatever/__init__.py
Normal file
0
test/examples/issue1209/whatever/test.py
Normal file
0
test/examples/issue1209/whatever/test.py
Normal file
@@ -9,7 +9,8 @@ import pytest
|
||||
|
||||
from jedi._compatibility import find_module_py33, find_module
|
||||
from jedi.evaluate import compiled
|
||||
from ..helpers import cwd_at
|
||||
from jedi.api.project import Project
|
||||
from ..helpers import cwd_at, get_example_dir
|
||||
|
||||
|
||||
@pytest.mark.skipif('sys.version_info < (3,3)')
|
||||
@@ -251,3 +252,16 @@ def test_compiled_import_none(monkeypatch, Script):
|
||||
"""
|
||||
monkeypatch.setattr(compiled, 'load_module', lambda *args, **kwargs: None)
|
||||
assert not Script('import sys').goto_definitions()
|
||||
|
||||
|
||||
def test_relative_imports_with_multiple_similar_directories(Script):
|
||||
dir = get_example_dir('issue1209')
|
||||
script = Script(
|
||||
"from .",
|
||||
path=os.path.join(dir, 'api/whatever/test_this.py')
|
||||
)
|
||||
# TODO pass this project to the script as a param once that's possible.
|
||||
script._evaluator.project = Project(dir)
|
||||
name, import_ = script.completions()
|
||||
assert import_.name == 'import'
|
||||
assert name.name == 'api_test1'
|
||||
|
||||
Reference in New Issue
Block a user