Skip to content

Commit

Permalink
fix restoring of original values for DEPRECATED_TEMPLATES and DEPRECA…
Browse files Browse the repository at this point in the history
…TED_TEMPLATE_CONSTANTS
  • Loading branch information
boegel committed Mar 27, 2024
1 parent 2a5eedb commit 2cfcc02
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/framework/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ def setUp(self):
github_token = gh.fetch_github_token(GITHUB_TEST_ACCOUNT)
self.skip_github_tests = github_token is None and os.getenv('FORCE_EB_GITHUB_TESTS') is None

self.orig_deprecated_constants = copy.deepcopy(easyconfig.templates.DEPRECATED_TEMPLATE_CONSTANTS)
self.orig_deprecated_templates = copy.deepcopy(easyconfig.templates.DEPRECATED_TEMPLATES)

def prep(self):
"""Prepare for test."""
# (re)cleanup last test file
Expand All @@ -133,6 +136,13 @@ def prep(self):
def tearDown(self):
""" make sure to remove the temporary file """
st.get_cpu_architecture = self.orig_get_cpu_architecture

easyconfig.templates.DEPRECATED_TEMPLATE_CONSTANTS = self.orig_deprecated_constants
easyconfig.templates.DEPRECATED_TEMPLATES = self.orig_deprecated_templates
reload(easyconfig.templates)
#reload(easyconfig.easyconfig)
#reload(easyconfig.format.pyheaderconfigobj)

super(EasyConfigTest, self).tearDown()
if os.path.exists(self.eb_file):
os.remove(self.eb_file)
Expand Down Expand Up @@ -1228,9 +1238,6 @@ def test_templating_constants(self):

def test_template_constant_deprecation(self):
"""Test that deprecation of easyconfig template constants works as expected"""
# backup original contents, DEPRECATED_TEMPLATE_CONSTANTS
orig_contents = copy.deepcopy(self.contents)
orig_deprecated_constants = copy.deepcopy(easyconfig.templates.DEPRECATED_TEMPLATE_CONSTANTS)

inp = {
'name': 'PI',
Expand Down Expand Up @@ -1288,10 +1295,6 @@ def test_template_constant_deprecation(self):
dirs = ec['sanity_check_paths']['dirs'][2]
self.assertTrue(inc_regex.match(dirs), "Pattern '%s' should match '%s'" % (inc_regex, dirs))

# restore non-deprecated backups
easyconfig.templates.DEPRECATED_TEMPLATE_CONSTANTS = orig_deprecated_constants
self.contents = orig_contents

def test_templating_cuda_toolchain(self):
"""Test templates via toolchain component, like setting %(cudaver)s with fosscuda toolchain."""

Expand Down Expand Up @@ -1486,7 +1489,6 @@ def test_sysroot_template(self):
def test_template_deprecation(self):
"""Test deprecation of templates"""

orig_deprecated_templates = copy.deepcopy(easyconfig.templates.DEPRECATED_TEMPLATES)
template_test_deprecations = {
'builddir': ('new_build_dir', '1000000000'),
'cudaver': ('new_cuda_ver', '1000000000'),
Expand Down Expand Up @@ -1514,8 +1516,6 @@ def test_template_deprecation(self):
f" is deprecated, use '{new}' instead")
self.assertIn(depr_str, stderr)

easyconfig.templates.DEPRECATED_TEMPLATES = orig_deprecated_templates

def test_constant_doc(self):
"""test constant documentation"""
doc = avail_easyconfig_constants()
Expand Down

0 comments on commit 2cfcc02

Please sign in to comment.