Skip to content

Commit a3cde1a

Browse files
committed
reset cached hooks in tests to avoid test hooks leaking into other tests
1 parent 29dbb71 commit a3cde1a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

test/framework/hooks.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from test.framework.utilities import EnhancedTestCase, TestLoaderFiltered, init_config
3333
from unittest import TextTestRunner
3434

35-
import easybuild.tools.hooks
35+
import easybuild.tools.hooks # so we can reset cached hooks
3636
from easybuild.tools.build_log import EasyBuildError
3737
from easybuild.tools.filetools import remove_file, write_file
3838
from easybuild.tools.hooks import find_hook, load_hooks, run_hook, verify_hooks
@@ -81,6 +81,14 @@ def setUp(self):
8181
])
8282
write_file(self.test_hooks_pymod, test_hooks_pymod_txt)
8383

84+
def tearDown(self):
85+
"""Cleanup."""
86+
87+
# reset cached hooks
88+
easybuild.tools.hooks._cached_hooks.clear()
89+
90+
super(HooksTest, self).tearDown()
91+
8492
def test_load_hooks(self):
8593
"""Test for load_hooks function."""
8694

test/framework/toy_build.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ def tearDown(self):
101101
del sys.modules['easybuild.easyblocks.toytoy']
102102
del sys.modules['easybuild.easyblocks.generic.toy_extension']
103103

104+
# reset cached hooks
105+
easybuild.tools.hooks._cached_hooks.clear()
106+
104107
super(ToyBuildTest, self).tearDown()
105108

106109
# remove logs

0 commit comments

Comments
 (0)