8000 Fixed the application of a consistent style to the unit tests · matplotlib/matplotlib@4da0e66 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4da0e66

Browse files
committed
Fixed the application of a consistent style to the unit tests
1 parent 8c33113 commit 4da0e66

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/matplotlib/testing/decorators.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ def _do_cleanup(original_units_registry):
7272
plt.close('all')
7373
gc.collect()
7474

75-
matplotlib.tests.setup()
76-
7775
matplotlib.units.registry.clear()
7876
matplotlib.units.registry.update(original_units_registry)
7977
warnings.resetwarnings() # reset any warning filters set in tests
@@ -83,6 +81,7 @@ class CleanupTest(object):
8381
@classmethod
8482
def setup_class(cls):
8583
cls.original_units_registry = matplotlib.units.registry.copy()
84+
matplotlib.tests.setup()
8685

8786
@classmethod
8887
def teardown_class(cls):
@@ -131,21 +130,25 @@ def check_freetype_version(ver):
131130
class ImageComparisonTest(CleanupTest):
132131
@classmethod
133132
def setup_class(cls):
134-
CleanupTest.setup_class()
135133
cls._initial_settings = mpl.rcParams.copy()
136134
try:
137135
matplotlib.style.use(cls._style)
138136
except:
139137
# Restore original settings before raising errors during the update.
140138
mpl.rcParams.update(cls._initial_settings)
141139
raise
142-
140+
# Because the setup of a CleanupTest might involve
141+
# modifying a few rcparams, this setup should come
142+
# last prior to running the image test.
143+
CleanupTest.setup_class()
143144
cls._func()
144145

145146
@classmethod
146147
def teardown_class(cls):
147-
CleanupTest.teardown_class()
148148
mpl.rcParams.update(cls._initial_settings)
149+
# Just as the setup of a CleanupTest should come last,
150+
# it would be prudent to make the teardown of CleanupTest last.
151+
CleanupTest.teardown_class()
149152

150153
@staticmethod
151154
def remove_text(figure):

0 commit comments

Comments
 (0)
0