mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-10 07:41:51 +08:00
_get_virtual_env_from_var: use safe=False
Without this creating an env from VIRTUAL_ENV will always silently fail if it is not the same/current environment.
This commit is contained in:
committed by
Dave Halter
parent
cdb760487b
commit
56bd795100
@@ -110,3 +110,22 @@ def test_create_environment_venv_path(venv_path):
|
||||
def test_create_environment_executable():
|
||||
environment = create_environment(sys.executable)
|
||||
assert environment.executable == sys.executable
|
||||
|
||||
|
||||
def test_get_default_environment_from_env_does_not_use_safe(tmpdir, monkeypatch):
|
||||
fake_python = os.path.join(str(tmpdir), 'fake_python')
|
||||
with open(fake_python, 'w') as f:
|
||||
f.write('')
|
||||
|
||||
def _get_subprocess(self):
|
||||
if self._start_executable != fake_python:
|
||||
raise RuntimeError('Should not get called!')
|
||||
self.executable = fake_python
|
||||
self.path = 'fake'
|
||||
|
||||
monkeypatch.setattr('jedi.api.environment.Environment._get_subprocess',
|
||||
_get_subprocess)
|
||||
|
||||
monkeypatch.setenv('VIRTUAL_ENV', fake_python)
|
||||
env = get_default_environment()
|
||||
assert env.path == 'fake'
|
||||
|
||||
Reference in New Issue
Block a user