_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:
Daniel Hahler
2018-08-13 17:44:19 +02:00
committed by Dave Halter
parent cdb760487b
commit 56bd795100
2 changed files with 25 additions and 1 deletions

View File

@@ -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'