Skip to content

Commit

Permalink
Keep test path config when restoring environment in tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Flamefire committed Sep 26, 2024
1 parent 9b4b7b3 commit 65b61be
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions test/framework/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from easybuild.framework.easyblock import EasyBlock
from easybuild.main import main
from easybuild.tools import config
from easybuild.tools.config import GENERAL_CLASS, Singleton, module_classes, update_build_option
from easybuild.tools.config import GENERAL_CLASS, Singleton, module_classes
from easybuild.tools.configobj import ConfigObj
from easybuild.tools.environment import modify_env
from easybuild.tools.filetools import copy_dir, mkdir, read_file, which
Expand Down Expand Up @@ -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[:]
Expand All @@ -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
Expand Down

0 comments on commit 65b61be

Please sign in to comment.