Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 224305c

Browse files
committed
Improve error message for image_comparison decorator.
The name of the test is already reported by pytest; the mismatching number of images is more useful. If a non-callable is passed to the decorator the test will fail normally and be reported as such by pytest; no need to check for it.
1 parent 91a2bb8 commit 224305c

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

lib/matplotlib/testing/decorators.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ def __init__(self, baseline_images, extensions, tol,
245245
self.style = style
246246

247247
def delayed_init(self, func):
248-
assert callable(func), "func must be callable"
249248
assert self.func is None, "it looks like same decorator used twice"
250249
self.func = func
251250
self.baseline_dir, self.result_dir = _image_directories(func)
@@ -258,8 +257,8 @@ def setup(self):
258257
matplotlib.testing.set_font_settings_for_testing()
259258
func()
260259
assert len(plt.get_fignums()) == len(self.baseline_images), (
261-
'Figures and baseline_images count are not the same'
262-
' (`%s`)' % getattr(func, '__qualname__', func.__name__))
260+
"Test generated {} images but there are {} baseline images"
261+
.format(len(plt.get_fignums()), len(self.baseline_images)))
263262
except:
264263
# Restore original settings before raising errors during the update.
265264
self.teardown_class()

0 commit comments

Comments
 (0)