File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515import numpy as np
1616
1717import matplotlib as mpl
18+ import matplotlib .style
1819import matplotlib .tests
1920import matplotlib .units
2021from matplotlib import cbook
2122from matplotlib import ticker
2223from matplotlib import pyplot as plt
2324from matplotlib import ft2font
24- from matplotlib .style import context as style_context
2525from matplotlib .testing .noseclasses import KnownFailureTest , \
2626 KnownFailureDidNotFailTest , ImageComparisonFailure
2727from matplotlib .testing .compare import comparable_formats , compare_images , \
@@ -132,9 +132,20 @@ class ImageComparisonTest(CleanupTest):
132132 @classmethod
133133 def setup_class (cls ):
134134 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 ()
135144
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 )
138149
139150 @staticmethod
140151 def remove_text (figure ):
You can’t perform that action at this time.
0 commit comments