From 9847816c1273f8237e3ed1e1e6ed57621771545a Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Thu, 12 Sep 2024 09:25:35 +0200 Subject: [PATCH] Keep test path config when restoring environment in tests This fixes `test_toy_multi_deps` which restores the environment in the middle of the test and then misses the --sourcepath modification done at test setup. --- test/framework/utilities.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/framework/utilities.py b/test/framework/utilities.py index c20de50624..0261922f58 100644 --- a/test/framework/utilities.py +++ b/test/framework/utilities.py @@ -106,8 +106,8 @@ def setUp(self): os.close(fd) self.cwd = os.getcwd() - # keep track of original environment to restore - self.orig_environ = copy.deepcopy(os.environ) + # keep track of original environment to restore after tests + self._initial_environ = copy.deepcopy(os.environ) # keep track of original environment/Python search path to restore self.orig_sys_path = sys.path[:] @@ -131,17 +131,19 @@ def setUp(self): if eb_path is not None: os.environ['EB_SCRIPT_PATH'] = eb_path + # disable progress bars when running the tests, + # since it messes with test suite progress output when test installations are performed + os.environ['EASYBUILD_DISABLE_SHOW_PROGRESS_BAR'] = '1' + + # Store the environment as setup (including the above paths) for tests to restore + self.orig_environ = copy.deepcopy(os.environ) + # make sure no deprecated behaviour is being triggered (unless intended by the test) self.orig_current_version = eb_build_log.CURRENT_VERSION self.disallow_deprecated_behaviour() init_config() - # disable progress bars when running the tests, - # since it messes with test suite progress output when test installations are performed - os.environ['EASYBUILD_DISABLE_SHOW_PROGRESS_BAR'] = '1' - update_build_option('show_progress_bar', False) - import easybuild # try to import easybuild.easyblocks(.generic) packages # it's OK if it fails here, but important to import first before fiddling with sys.path