forked from VimPlug/jedi
tests: use monkeypatch.setenv
This commit is contained in:
committed by
Dave Halter
parent
3a62d54403
commit
08fa7941ce
@@ -1,6 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from contextlib import contextmanager
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@@ -85,34 +84,22 @@ def test_killed_subprocess(evaluator, Script):
|
|||||||
assert def_.name == 'str'
|
assert def_.name == 'str'
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
def test_not_existing_virtualenv(monkeypatch):
|
||||||
def set_environment_variable(name, value):
|
|
||||||
tmp = os.environ.get(name)
|
|
||||||
try:
|
|
||||||
os.environ[name] = value
|
|
||||||
yield
|
|
||||||
finally:
|
|
||||||
if tmp is None:
|
|
||||||
del os.environ[name]
|
|
||||||
else:
|
|
||||||
os.environ[name] = tmp
|
|
||||||
|
|
||||||
|
|
||||||
def test_not_existing_virtualenv():
|
|
||||||
"""Should not match the path that was given"""
|
"""Should not match the path that was given"""
|
||||||
path = '/foo/bar/jedi_baz'
|
path = '/foo/bar/jedi_baz'
|
||||||
with set_environment_variable('VIRTUAL_ENV', path):
|
monkeypatch.setenv('VIRTUAL_ENV', path)
|
||||||
assert get_default_environment().executable != path
|
assert get_default_environment().executable != path
|
||||||
|
|
||||||
|
|
||||||
def test_working_venv(venv_path):
|
def test_working_venv(venv_path, monkeypatch):
|
||||||
with set_environment_variable('VIRTUAL_ENV', venv_path):
|
monkeypatch.setenv('VIRTUAL_ENV', venv_path)
|
||||||
assert get_default_environment().path == venv_path
|
assert get_default_environment().path == venv_path
|
||||||
|
|
||||||
|
|
||||||
def test_scanning_venvs(venv_path):
|
def test_scanning_venvs(venv_path):
|
||||||
parent_dir = os.path.dirname(venv_path)
|
parent_dir = os.path.dirname(venv_path)
|
||||||
assert any(venv.path == venv_path for venv in find_virtualenvs([parent_dir]))
|
assert any(venv.path == venv_path
|
||||||
|
for venv in find_virtualenvs([parent_dir]))
|
||||||
|
|
||||||
|
|
||||||
def test_create_environment_venv_path(venv_path):
|
def test_create_environment_venv_path(venv_path):
|
||||||
|
|||||||
Reference in New Issue
Block a user