Always disable leftover active environment after tests

This commit is contained in:
Harmen Stoppels 2021-09-01 14:23:26 +02:00 committed by Todd Gamblin
parent de492e73d5
commit 64407e253c

View file

@ -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)
def clean_user_environment():
env_var = ev.spack_env_var in os.environ
active = ev._active_environment
if env_var:
spack_env_value = os.environ.pop(ev.spack_env_var)
if active:
ev.deactivate()
spack_env_value = os.environ.pop(ev.spack_env_var, None)
with ev.deactivate_environment():
yield
if env_var:
if 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):