mirror of
https://github.com/davidhalter/jedi.git
synced 2026-11-02 05:47:31 +08:00
Restructure relative importing a bit and improve tests
This commit is contained in:
1 parent
467c2e5def
commit
23d61e5e97
2 files changed
+31
-20
No files matched your search
@@ -277,14 +277,22 @@ def test_get_modules_containing_name(evaluator, path, goal):
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'path', ('api/whatever/test_this.py', 'api/whatever/file'))
|
||||
def test_relative_imports_with_multiple_similar_directories(Script, path):
|
||||
@pytest.mark.parametrize('empty_sys_path', (False, True))
|
||||
def test_relative_imports_with_multiple_similar_directories(Script, path, empty_sys_path):
|
||||
dir = get_example_dir('issue1209')
|
||||
script = Script(
|
||||
"from .",
|
||||
path=os.path.join(dir, path)
|
||||
)
|
||||
# TODO pass this project to the script as a param once that's possible.
|
||||
script._evaluator.project = Project(dir)
|
||||
if empty_sys_path:
|
||||
script = Script(
|
||||
"from .",
|
||||
path=os.path.join(dir, path),
|
||||
)
|
||||
script._evaluator.project = Project(dir, smart_sys_path=False)
|
||||
else:
|
||||
script = Script(
|
||||
"from .",
|
||||
path=os.path.join(dir, path),
|
||||
)
|
||||
# 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