Skip to content

Commit

Permalink
see if reloading the full module works
Browse files Browse the repository at this point in the history
  • Loading branch information
sroet committed Feb 27, 2024
1 parent 64651ad commit 0555e1c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tests/test_broken_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ def test_missing_matplotlib(self):
import matplotlib
# force reload
# check if we can still import pytom_tm
pytom_tm = reload(pytom_tm)

# check if plotting is indeed disabled
self.assertFalse(pytom_tm.template.plotting_available)
self.assertFalse(pytom_tm.extract.plotting_available)
reload(pytom_tm)

# check if plotting is indeed disabled after reload
# (reload is needed to prevent python import caching)
self.assertFalse(reload(pytom_tm.template).plotting_available)
self.assertFalse(reload(pytom_tm.extract).plotting_available)
# assert that importing the plotting module fails completely
with self.assertRaisesRegex(RuntimeError, "matplotlib and seaborn"):
import pytom_tm.plotting
Expand All @@ -74,10 +75,11 @@ def test_missing_seaborn(self):
with self.assertRaisesRegex(ModuleNotFoundError, 'seaborn'):
import seaborn
# check if we can still import pytom_tm
pytom_tm = reload(pytom_tm)
reload(pytom_tm)
# check if plotting is indeed disabled
self.assertFalse(pytom_tm.template.plotting_available)
self.assertFalse(pytom_tm.extract.plotting_available)
# (reload is needed to prevent python import caching)
self.assertFalse(reload(pytom_tm.template).plotting_available)
self.assertFalse(reload(pytom_tm.extract).plotting_available)
# assert that importing the plotting module fails completely
with self.assertRaisesRegex(RuntimeError, "matplotlib and seaborn"):
import pytom_tm.plotting
Expand Down

0 comments on commit 0555e1c

Please sign in to comment.