Skip to content

Commit 5b082a5

Browse files
committed
Merge pull request matplotlib#2567 from megies/compare_image_exceptions
more informative exceptions for empty/not-existing images in compare_images()
2 parents f8687b0 + f3fa220 commit 5b082a5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/matplotlib/testing/compare.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,13 @@ def compare_images( expected, actual, tol, in_decorator=False ):
280280
- in_decorator If called from image_comparison decorator, this should be
281281
True. (default=False)
282282
'''
283+
if not os.path.exists(actual):
284+
msg = "Output image %s does not exist." % actual
285+
raise Exception(msg)
286+
287+
if os.stat(actual).st_size == 0:
288+
msg = "Output image file %s is empty." % actual
289+
raise Exception(msg)
283290

284291
verify(actual)
285292

0 commit comments

Comments
 (0)