|
21 | 21 | from matplotlib import ticker |
22 | 22 | from matplotlib import pyplot as plt |
23 | 23 | from matplotlib import ft2font |
| 24 | +from matplotlib.style import context as style_context |
24 | 25 | from matplotlib.testing.noseclasses import KnownFailureTest, \ |
25 | 26 | KnownFailureDidNotFailTest, ImageComparisonFailure |
26 | 27 | from matplotlib.testing.compare import comparable_formats, compare_images, \ |
@@ -132,7 +133,8 @@ class ImageComparisonTest(CleanupTest): |
132 | 133 | def setup_class(cls): |
133 | 134 | CleanupTest.setup_class() |
134 | 135 |
|
135 | | - cls._func() |
| 136 | + with style_context(cls._style): |
| 137 | + cls._func() |
136 | 138 |
|
137 | 139 | @staticmethod |
138 | 140 | def remove_text(figure): |
@@ -206,7 +208,7 @@ def do_test(): |
206 | 208 |
|
207 | 209 | def image_comparison(baseline_images=None, extensions=None, tol=13, |
208 | 210 | freetype_version=None, remove_text=False, |
209 | | - savefig_kwarg=None): |
| 211 | + savefig_kwarg=None, style='classic'): |
210 | 212 | """ |
211 | 213 | call signature:: |
212 | 214 |
|
@@ -243,6 +245,11 @@ def image_comparison(baseline_images=None, extensions=None, tol=13, |
243 | 245 | *savefig_kwarg*: dict |
244 | 246 | Optional arguments that are passed to the savefig method. |
245 | 247 |
|
| 248 | + *style*: string |
| 249 | + Optional name for the base style to apply to the image |
| 250 | + test. The test itself can also apply additional styles |
| 251 | + if desired. Defaults to the 'classic' style. |
| 252 | +
|
246 | 253 | """ |
247 | 254 |
|
248 | 255 | if baseline_images is None: |
@@ -280,7 +287,8 @@ def compare_images_decorator(func): |
280 | 287 | '_tol': tol, |
281 | 288 | '_freetype_version': freetype_version, |
282 | 289 | '_remove_text': remove_text, |
283 | | - '_savefig_kwarg': savefig_kwarg}) |
| 290 | + '_savefig_kwarg': savefig_kwarg, |
| 291 | + '_style': style}) |
284 | 292 |
|
285 | 293 | return new_class |
286 | 294 | return compare_images_decorator |
|
0 commit comments