Always disable leftover active environment after tests
This commit is contained in:
parent
de492e73d5
commit
64407e253c
@ -92,24 +92,24 @@ def no_path_access(monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Disable any activate Spack environment BEFORE all tests
|
# Disable any active Spack environment BEFORE all tests
|
||||||
#
|
#
|
||||||
@pytest.fixture(scope='session', autouse=True)
|
@pytest.fixture(scope='session', autouse=True)
|
||||||
def clean_user_environment():
|
def clean_user_environment():
|
||||||
env_var = ev.spack_env_var in os.environ
|
spack_env_value = os.environ.pop(ev.spack_env_var, None)
|
||||||
active = ev._active_environment
|
with ev.deactivate_environment():
|
||||||
|
yield
|
||||||
if env_var:
|
if spack_env_value:
|
||||||
spack_env_value = os.environ.pop(ev.spack_env_var)
|
|
||||||
if active:
|
|
||||||
ev.deactivate()
|
|
||||||
|
|
||||||
yield
|
|
||||||
|
|
||||||
if env_var:
|
|
||||||
os.environ[ev.spack_env_var] = spack_env_value
|
os.environ[ev.spack_env_var] = spack_env_value
|
||||||
if active:
|
|
||||||
ev.activate(active)
|
|
||||||
|
#
|
||||||
|
# Make sure global state of active env does not leak between tests.
|
||||||
|
#
|
||||||
|
@pytest.fixture(scope='function', autouse=True)
|
||||||
|
def clean_test_environment():
|
||||||
|
yield
|
||||||
|
ev.deactivate()
|
||||||
|
|
||||||
|
|
||||||
def _verify_executables_noop(*args):
|
def _verify_executables_noop(*args):
|
||||||
|
Loading…
Reference in New Issue
Block a user