|
1 | 1 | """
|
2 | 2 | Provides a collection of utilities for comparing (image) results.
|
3 |
| -
|
4 | 3 | """
|
5 | 4 |
|
6 | 5 | import atexit
|
7 | 6 | import hashlib
|
| 7 | +import logging |
8 | 8 | import os
|
9 | 9 | from pathlib import Path
|
10 | 10 | import re
|
|
19 | 19 | import matplotlib as mpl
|
20 | 20 | from matplotlib.testing.exceptions import ImageComparisonFailure
|
21 | 21 |
|
| 22 | +_log = logging.getLogger(__name__) |
| 23 | + |
22 | 24 | __all__ = ['compare_images', 'comparable_formats']
|
23 | 25 |
|
24 | 26 |
|
@@ -285,12 +287,15 @@ def convert(filename, cache):
|
285 | 287 | new_ext = os.path.splitext(newname)[1]
|
286 | 288 | cached_file = os.path.join(cache_dir, hash_value + new_ext)
|
287 | 289 | if os.path.exists(cached_file):
|
| 290 | + _log.debug("For %s: reusing cached conversion.", filename) |
288 | 291 | shutil.copyfile(cached_file, newname)
|
289 | 292 | return newname
|
290 | 293 |
|
| 294 | + _log.debug("For %s: converting to png.", filename) |
291 | 295 | converter[extension](filename, newname)
|
292 | 296 |
|
293 | 297 | if cache_dir is not None:
|
| 298 | + _log.debug("For %s: caching conversion result.", filename) |
294 | 299 | shutil.copyfile(newname, cached_file)
|
295 | 300 |
|
296 | 301 | return newname
|
@@ -382,7 +387,7 @@ def compare_images(expected, actual, tol, in_decorator=False):
|
382 | 387 | raise IOError('Baseline image %r does not exist.' % expected)
|
383 | 388 | extension = expected.split('.')[-1]
|
384 | 389 | if extension != 'png':
|
385 |
| - actual = convert(actual, cache=False) |
| 390 | + actual = convert(actual, cache=True) |
386 | 391 | expected = convert(expected, cache=True)
|
387 | 392 |
|
388 | 393 | # open the image files and remove the alpha channel (if it exists)
|
|
0 commit comments