@@ -63,29 +63,32 @@ def teardown_class(cls):
6363 matplotlib .units .registry .update (cls .original_units_registry )
6464
6565 def test (self ):
66- self .func ()
66+ self ._func ()
6767
6868def cleanup (func ):
69+ name = func .__name__
70+ func = staticmethod (func )
71+ func .__func__ .__name__ = '_private'
6972 new_class = new .classobj (
70- func . __name__ ,
73+ name ,
7174 (CleanupTest ,),
72- {'func ' : staticmethod ( func ) })
75+ {'_func ' : func })
7376 return new_class
7477
7578class ImageComparisonTest (CleanupTest ):
7679 @classmethod
7780 def setup_class (cls ):
7881 CleanupTest .setup_class ()
7982
80- cls .func ()
83+ cls ._func ()
8184
8285 def test (self ):
83- baseline_dir , result_dir = _image_directories (self .func )
86+ baseline_dir , result_dir = _image_directories (self ._func )
8487
85- for fignum , baseline in zip (plt .get_fignums (), self .baseline_images ):
88+ for fignum , baseline in zip (plt .get_fignums (), self ._baseline_images ):
8689 figure = plt .figure (fignum )
8790
88- for extension in self .extensions :
91+ for extension in self ._extensions :
8992 will_fail = not extension in comparable_formats ()
9093 if will_fail :
9194 fail_msg = 'Cannot compare %s files on this system' % extension
@@ -111,7 +114,7 @@ def do_test():
111114 raise ImageComparisonFailure (
112115 'image does not exist: %s' % expected_fname )
113116
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 )
115118 if err :
116119 raise ImageComparisonFailure (
117120 'images not close: %(actual)s vs. %(expected)s '
@@ -157,13 +160,20 @@ def compare_images_decorator(func):
157160 # "teardown_class" methods. Creating a class instance doesn't
158161 # work, so we use new.classobj to actually create a class and
159162 # 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'
160170 new_class = new .classobj (
161- func . __name__ ,
171+ name ,
162172 (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 })
167177 return new_class
168178 return compare_images_decorator
169179
0 commit comments