mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 14:54:47 +08:00
Merge branch 'master' of github.com:davidhalter/jedi
This commit is contained in:
@@ -189,10 +189,15 @@ def _get_executable_path(path, safe=True):
|
|||||||
Returns None if it's not actually a virtual env.
|
Returns None if it's not actually a virtual env.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
bin_name = 'Scripts' if os.name == 'nt' else 'bin'
|
if os.name == 'nt':
|
||||||
|
bin_name = 'Scripts'
|
||||||
|
extension = '.exe'
|
||||||
|
else:
|
||||||
|
bin_name = 'bin'
|
||||||
|
extension = ''
|
||||||
bin_folder = os.path.join(path, bin_name)
|
bin_folder = os.path.join(path, bin_name)
|
||||||
activate = os.path.join(bin_folder, 'activate')
|
activate = os.path.join(bin_folder, 'activate')
|
||||||
python = os.path.join(bin_folder, 'python')
|
python = os.path.join(bin_folder, 'python' + extension)
|
||||||
if not all(os.path.exists(p) for p in (activate, python)):
|
if not all(os.path.exists(p) for p in (activate, python)):
|
||||||
raise InvalidPythonEnvironment("One of bin/activate and bin/python is missing.")
|
raise InvalidPythonEnvironment("One of bin/activate and bin/python is missing.")
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,14 @@ def test_paths_from_assignment(Script):
|
|||||||
expr_stmt = script._module_node.children[0]
|
expr_stmt = script._module_node.children[0]
|
||||||
return set(sys_path._paths_from_assignment(script._get_module(), expr_stmt))
|
return set(sys_path._paths_from_assignment(script._get_module(), expr_stmt))
|
||||||
|
|
||||||
assert paths('sys.path[0:0] = ["a"]') == {'/foo/a'}
|
# Normalize paths for Windows.
|
||||||
assert paths('sys.path = ["b", 1, x + 3, y, "c"]') == {'/foo/b', '/foo/c'}
|
path_a = os.path.abspath('/foo/a')
|
||||||
assert paths('sys.path = a = ["a"]') == {'/foo/a'}
|
path_b = os.path.abspath('/foo/b')
|
||||||
|
path_c = os.path.abspath('/foo/c')
|
||||||
|
|
||||||
|
assert paths('sys.path[0:0] = ["a"]') == {path_a}
|
||||||
|
assert paths('sys.path = ["b", 1, x + 3, y, "c"]') == {path_b, path_c}
|
||||||
|
assert paths('sys.path = a = ["a"]') == {path_a}
|
||||||
|
|
||||||
# Fail for complicated examples.
|
# Fail for complicated examples.
|
||||||
assert paths('sys.path, other = ["a"], 2') == set()
|
assert paths('sys.path, other = ["a"], 2') == set()
|
||||||
|
|||||||
Reference in New Issue
Block a user