@@ -72,8 +72,6 @@ def _do_cleanup(original_units_registry):
72
72
plt .close ('all' )
73
73
gc .collect ()
74
74
75
- matplotlib .tests .setup ()
76
-
77
75
matplotlib .units .registry .clear ()
78
76
matplotlib .units .registry .update (original_units_registry )
79
77
warnings .resetwarnings () # reset any warning filters set in tests
@@ -83,6 +81,7 @@ class CleanupTest(object):
83
81
@classmethod
84
82
def setup_class (cls ):
85
83
cls .original_units_registry = matplotlib .units .registry .copy ()
84
+ matplotlib .tests .setup ()
86
85
87
86
@classmethod
88
87
def teardown_class (cls ):
@@ -131,21 +130,25 @@ def check_freetype_version(ver):
131
130
class ImageComparisonTest (CleanupTest ):
132
131
@classmethod
133
132
def setup_class (cls ):
134
- CleanupTest .setup_class ()
135
133
cls ._initial_settings = mpl .rcParams .copy ()
136
134
try :
137
135
matplotlib .style .use (cls ._style )
138
136
except :
139
137
# Restore original settings before raising errors during the update.
140
138
mpl .rcParams .update (cls ._initial_settings )
141
139
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 ()
143
144
cls ._func ()
144
145
145
146
@classmethod
146
147
def teardown_class (cls ):
147
- CleanupTest .teardown_class ()
148
148
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 ()
149
152
150
153
@staticmethod
151
154
def remove_text (figure ):
0 commit comments