File tree 1 file changed +22
-1
lines changed 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 18
18
from matplotlib .testing .compare import comparable_formats , compare_images , \
19
19
make_test_filename
20
20
import warnings
21
+ import unittest
21
22
22
23
def knownfailureif (fail_condition , msg = None , known_exception_class = None ):
23
24
"""
@@ -58,6 +59,7 @@ def failer(*args, **kwargs):
58
59
return nose .tools .make_decorator (f )(failer )
59
60
return known_fail_decorator
60
61
62
+
61
63
class CleanupTest (object ):
62
64
@classmethod
63
65
def setup_class (cls ):
@@ -71,11 +73,30 @@ def teardown_class(cls):
71
73
72
74
matplotlib .units .registry .clear ()
73
75
matplotlib .units .registry .update (cls .original_units_registry )
74
- warnings .resetwarnings () # reset any warning filters set in tests
76
+ warnings .resetwarnings () # reset any warning filters set in tests
75
77
76
78
def test (self ):
77
79
self ._func ()
78
80
81
+
82
+ class CleanupTestCase (unittest .TestCase ):
83
+ '''A wrapper for unittest.TestCase that includes cleanup operations'''
84
+ @classmethod
85
+ def setUpClass (cls ):
86
+ import matplotlib .units
87
+ cls .original_units_registry = matplotlib .units .registry .copy ()
88
+
89
+ @classmethod
90
+ def tearDownClass (cls ):
91
+ plt .close ('all' )
92
+
93
+ matplotlib .tests .setup ()
94
+
95
+ matplotlib .units .registry .clear ()
96
+ matplotlib .units .registry .update (cls .original_units_registry )
97
+ warnings .resetwarnings () # reset any warning filters set in tests
98
+
99
+
79
100
def cleanup (func ):
80
101
name = func .__name__
81
102
func = staticmethod (func )
You can’t perform that action at this time.
0 commit comments