CI: better cleanup for modules in between tests
This commit is contained in:
parent
c407e9ef28
commit
9d9b1b1952
5 changed files with 41 additions and 12 deletions
|
@ -7,3 +7,14 @@ V = 'HPI_TESTS_KARLICOSS'
|
|||
skip_if_not_karlicoss = pytest.mark.skipif(
|
||||
V not in os.environ, reason=f'test only works on @karlicoss data for now. Set evn variable {V}=true to override.',
|
||||
)
|
||||
|
||||
def reset_modules() -> None:
|
||||
'''
|
||||
A hack to 'unload' HPI modules, otherwise some modules might cache the config
|
||||
TODO: a bit crap, need a better way..
|
||||
'''
|
||||
import sys
|
||||
import re
|
||||
to_unload = [m for m in sys.modules if re.match(r'my[.]?', m)]
|
||||
for m in to_unload:
|
||||
del sys.modules[m]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue