Always disable leftover active environment after tests
This commit is contained in:
parent
de492e73d5
commit
64407e253c
1 changed files with 14 additions and 14 deletions
|
@ -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()
|
||||
|
||||
yield
|
||||
|
||||
if env_var:
|
||||
spack_env_value = os.environ.pop(ev.spack_env_var, None)
|
||||
with ev.deactivate_environment():
|
||||
yield
|
||||
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):
|
||||
|
|
Loading…
Reference in a new issue