Skip to content

Commit c3ba918

Browse files
committed
Merge remote-tracking branch 'upstream/master' into always_compare
2 parents e2cdacd + 63afd42 commit c3ba918

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

pytest_mpl/plugin.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,8 @@ def compare_image_to_hash_library(self, item, fig, result_dir):
499499
hash_comparison_pass = True
500500
else:
501501
error_message = (f"Hash {test_hash} doesn't match hash "
502-
f"{hash_library[hash_name]} in library "
503-
f"{hash_library_filename} for test {hash_name}.")
502+
f"{hash_library[hash_name]} in library "
503+
f"{hash_library_filename} for test {hash_name}.")
504504

505505
# If the compare has only been specified with hash and not baseline
506506
# dir, don't attempt to find a baseline image at the default path.
@@ -512,24 +512,20 @@ def compare_image_to_hash_library(self, item, fig, result_dir):
512512
# Ignore Errors here as it's possible the reference image dosen't exist yet.
513513
try:
514514
baseline_image_path = self.obtain_baseline_image(item, result_dir)
515+
baseline_image = baseline_image_path
516+
baseline_image = None if (baseline_image and not baseline_image.exists()) else baseline_image
515517
# Get the baseline and generate a diff image, always so that
516518
# --mpl-results-always can be respected.
517519
baseline_comparison = self.compare_image_to_baseline(item, fig, result_dir)
518-
except Exception as e:
519-
warnings.warn(str(e))
520-
521-
try:
522-
baseline_image = baseline_image_path
523-
baseline_image = None if (baseline_image and not baseline_image.exists()) else baseline_image
524-
except Exception:
525-
baseline_image = None
520+
except Exception as baseline_error:
521+
baseline_image = None
526522

527523
# If the hash comparison passes then return
528524
if hash_comparison_pass:
529525
return
530526

531527
if baseline_image is None:
532-
error_message += f"\nUnable to find baseline image {baseline_image_path or ''}."
528+
error_message += f"\nUnable to find baseline image for {item}.\n{baseline_error}"
533529
return error_message
534530

535531
# Override the tolerance (if not explicitly set) to 0 as the hashes are not forgiving

tests/baseline/hashes/mpl33_ft261.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"test_pytest_mpl.test_parametrized[5]": "04c998af2d7932ca4a851d610e8a020d94a2f623d1301dbe9b59fe6efd28a5f7",
1010
"test_pytest_mpl.test_parametrized[50]": "937d986ab6b209e7d48eb30cc30e9db62c93bbc4c86768e276a5b454e63bca93",
1111
"test_pytest_mpl.test_parametrized[500]": "e39ed724b0762b8736879801e32dc0c1525afd03c0567a43b119435aaa608498",
12-
"test_pytest_mpl.test_hash_succeeds": "4150d2d146801b5feb41ef6bd022d5baabf4811c7f2e9ed72b639e80904243e1"
12+
"test_pytest_mpl.test_hash_succeeds": "55ad74a44c99606f1df1e79f67a59a4986bddc2b48ea2b2d7ea8365db91dc7ca"
1313
}

0 commit comments

Comments
 (0)