@@ -293,6 +293,7 @@ def __init__(self,
293
293
294
294
# We need global state to store all the hashes generated over the run
295
295
self ._generated_hash_library = {}
296
+ self ._test_results = {}
296
297
297
298
def get_compare (self , item ):
298
299
"""
@@ -506,28 +507,27 @@ def compare_image_to_hash_library(self, item, fig, result_dir):
506
507
if not hash_comparison_pass and not self .baseline_directory_specified (item ) or new_test :
507
508
return error_message
508
509
509
- # Get the baseline and generate a diff image, always so that
510
- # --mpl-results-always can be respected.
511
- # Ignore Errors here as it's possible the reference image dosen't exist yet.
512
- try :
513
- baseline_comparison = self .compare_image_to_baseline (item , fig , result_dir )
514
- except Exception as e :
515
- pass
516
-
517
- # If the hash comparison passes then return
518
- if hash_comparison_pass :
519
- return
520
-
521
510
# If this is not a new test try and get the baseline image.
522
511
if not new_test :
523
- baseline_image_path = self .obtain_baseline_image (item , result_dir )
512
+ # Ignore Errors here as it's possible the reference image dosen't exist yet.
513
+ try :
514
+ baseline_image_path = self .obtain_baseline_image (item , result_dir )
515
+ # Get the baseline and generate a diff image, always so that
516
+ # --mpl-results-always can be respected.
517
+ baseline_comparison = self .compare_image_to_baseline (item , fig , result_dir )
518
+ except Exception as e :
519
+ warnings .warn (str (e ))
524
520
525
521
try :
526
522
baseline_image = baseline_image_path
527
523
baseline_image = None if (baseline_image and not baseline_image .exists ()) else baseline_image
528
524
except Exception :
529
525
baseline_image = None
530
526
527
+ # If the hash comparison passes then return
528
+ if hash_comparison_pass :
529
+ return
530
+
531
531
if baseline_image is None :
532
532
error_message += f"\n Unable to find baseline image { baseline_image_path or '' } ."
533
533
return error_message
@@ -581,6 +581,8 @@ def item_function_wrapper(*args, **kwargs):
581
581
if remove_text :
582
582
remove_ticks_and_titles (fig )
583
583
584
+ test_name = self .generate_test_name (item )
585
+
584
586
# What we do now depends on whether we are generating the
585
587
# reference images or simply running the test.
586
588
if self .generate_dir is not None :
@@ -589,8 +591,7 @@ def item_function_wrapper(*args, **kwargs):
589
591
pytest .skip ("Skipping test, since generating image." )
590
592
591
593
if self .generate_hash_library is not None :
592
- hash_name = self .generate_test_name (item )
593
- self ._generated_hash_library [hash_name ] = self .generate_image_hash (item , fig )
594
+ self ._generated_hash_library [test_name ] = self .generate_image_hash (item , fig )
594
595
pytest .skip ("Skipping test as generating hash library." )
595
596
596
597
# Only test figures if we are not generating hashes or images
@@ -607,6 +608,8 @@ def item_function_wrapper(*args, **kwargs):
607
608
608
609
close_mpl_figure (fig )
609
610
611
+ self ._test_results [str (pathify (test_name ))] = msg or True
612
+
610
613
if msg is None :
611
614
if not self .results_always :
612
615
shutil .rmtree (result_dir )
@@ -629,8 +632,10 @@ def generate_summary_html(self, dir_list):
629
632
f .write (HTML_INTRO )
630
633
631
634
for directory in dir_list :
635
+ test_name = directory .parts [- 1 ]
636
+ test_result = 'passed' if self ._test_results [test_name ] is True else 'failed'
632
637
f .write ('<tr>'
633
- f'<td>{ directory . parts [ - 1 ] } \n '
638
+ f'<td>{ test_name } ( { test_result } ) \n '
634
639
f'<td><img src="{ directory / "baseline.png" } "></td>\n '
635
640
f'<td><img src="{ directory / "result-failed-diff.png" } "></td>\n '
636
641
f'<td><img src="{ directory / "result.png" } "></td>\n '
0 commit comments