mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-16 02:27:06 +08:00
Use sys path mostly from project and move some sys path stuff around.
This commit is contained in:
@@ -10,13 +10,13 @@ from jedi import Script
|
||||
|
||||
def test_paths_from_assignment():
|
||||
def paths(src):
|
||||
script = Script(src)
|
||||
script = Script(src, path='/foo/bar.py')
|
||||
expr_stmt = script._get_module_node().children[0]
|
||||
return set(sys_path._paths_from_assignment(script._get_module(), expr_stmt))
|
||||
|
||||
assert paths('sys.path[0:0] = ["a"]') == set(['a'])
|
||||
assert paths('sys.path = ["b", 1, x + 3, y, "c"]') == set(['b', 'c'])
|
||||
assert paths('sys.path = a = ["a"]') == set(['a'])
|
||||
assert paths('sys.path[0:0] = ["a"]') == set(['/foo/a'])
|
||||
assert paths('sys.path = ["b", 1, x + 3, y, "c"]') == set(['/foo/b', '/foo/c'])
|
||||
assert paths('sys.path = a = ["a"]') == set(['/foo/a'])
|
||||
|
||||
# Fail for complicated examples.
|
||||
assert paths('sys.path, other = ["a"], 2') == set()
|
||||
|
||||
Reference in New Issue
Block a user