@@ -63,29 +63,32 @@ def teardown_class(cls):
63
63
matplotlib .units .registry .update (cls .original_units_registry )
64
64
65
65
def test (self ):
66
- self .func ()
66
+ self ._func ()
67
67
68
68
def cleanup (func ):
69
+ name = func .__name__
70
+ func = staticmethod (func )
71
+ func .__func__ .__name__ = '_private'
69
72
new_class = new .classobj (
70
- func . __name__ ,
73
+ name ,
71
74
(CleanupTest ,),
72
- {'func ' : staticmethod ( func ) })
75
+ {'_func ' : func })
73
76
return new_class
74
77
75
78
class ImageComparisonTest (CleanupTest ):
76
79
@classmethod
77
80
def setup_class (cls ):
78
81
CleanupTest .setup_class ()
79
82
80
- cls .func ()
83
+ cls ._func ()
81
84
82
85
def test (self ):
83
- baseline_dir , result_dir = _image_directories (self .func )
86
+ baseline_dir , result_dir = _image_directories (self ._func )
84
87
85
- for fignum , baseline in zip (plt .get_fignums (), self .baseline_images ):
88
+ for fignum , baseline in zip (plt .get_fignums (), self ._baseline_images ):
86
89
figure = plt .figure (fignum )
87
90
88
- for extension in self .extensions :
91
+ for extension in self ._extensions :
89
92
will_fail = not extension in comparable_formats ()
90
93
if will_fail :
91
94
fail_msg = 'Cannot compare %s files on this system' % extension
@@ -111,7 +114,7 @@ def do_test():
111
114
raise ImageComparisonFailure (
112
115
'image does not exist: %s' % expected_fname )
113
116
114
- err = compare_images (expected_fname , actual_fname , self .tol , in_decorator = True )
117
+ err = compare_images (expected_fname , actual_fname , self ._tol , in_decorator = True )
115
118
if err :
116
119
raise ImageComparisonFailure (
117
120
'images not close: %(actual)s vs. %(expected)s '
@@ -157,13 +160,20 @@ def compare_images_decorator(func):
157
160
# "teardown_class" methods. Creating a class instance doesn't
158
161
# work, so we use new.classobj to actually create a class and
159
162
# fill it with the appropriate methods.
163
+ name = func .__name__
164
+ # For nose 1.0, we need to rename the test function to
165
+ # something without the word "test", or it will be run as
166
+ # well, outside of the context of our image comparison test
167
+ # generator.
168
+ func = staticmethod (func )
169
+ func .__func__ .__name__ = '_private'
160
170
new_class = new .classobj (
161
- func . __name__ ,
171
+ name ,
162
172
(ImageComparisonTest ,),
163
- {'func ' : staticmethod ( func ) ,
164
- 'baseline_images ' : baseline_images ,
165
- 'extensions ' : extensions ,
166
- 'tol ' : tol })
173
+ {'_func ' : func ,
174
+ '_baseline_images ' : baseline_images ,
175
+ '_extensions ' : extensions ,
176
+ '_tol ' : tol })
167
177
return new_class
168
178
return compare_images_decorator
169
179
0 commit comments