File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 15
15
import numpy as np
16
16
17
17
import matplotlib as mpl
18
+ import matplotlib .style
18
19
import matplotlib .tests
19
20
import matplotlib .units
20
21
from matplotlib import cbook
21
22
from matplotlib import ticker
22
23
from matplotlib import pyplot as plt
23
24
from matplotlib import ft2font
24
- from matplotlib .style import context as style_context
25
25
from matplotlib .testing .noseclasses import KnownFailureTest , \
26
26
KnownFailureDidNotFailTest , ImageComparisonFailure
27
27
from matplotlib .testing .compare import comparable_formats , compare_images , \
@@ -132,9 +132,20 @@ class ImageComparisonTest(CleanupTest):
132
132
@classmethod
133
133
def setup_class (cls ):
134
134
CleanupTest .setup_class ()
135
+ cls ._initial_settings = mpl .rcParams .copy ()
136
+ try :
137
+ matplotlib .style .use (cls ._style )
138
+ except :
139
+ # Restore original settings before raising errors during the update.
140
+ mpl .rcParams .update (cls ._initial_settings )
141
+ raise
142
+
143
+ cls ._func ()
135
144
136
- with style_context (cls ._style ):
137
- cls ._func ()
145
+ @classmethod
146
+ def teardown_class (cls ):
147
+ CleanupTest .teardown_class ()
148
+ mpl .rcParams .update (cls ._initial_settings )
138
149
139
150
@staticmethod
140
151
def remove_text (figure ):
You can’t perform that action at this time.
0 commit comments