@@ -26,26 +26,12 @@ class Results:
2626 def __init__ (self , results , title = "Image comparison" ):
2727 self .title = title # HTML <title>
2828
29- # If any baseline images or baseline hashes are present,
30- # assume all results should have them
31- self .warn_missing = {'baseline_image' : False , 'baseline_hash' : False }
32- for key in self .warn_missing .keys ():
33- for result in results .values ():
34- if result [key ] is not None :
35- self .warn_missing [key ] = True
36- break
37-
38- # Additional <body> classes
39- self .classes = []
40- if self .warn_missing ['baseline_hash' ] is False :
41- self .classes += ['no-hash-test' ]
42-
4329 # Generate sorted list of results
4430 self .cards = []
4531 pad = len (str (len (results .items ()))) # maximum length of a result index
4632 for collect_n , (name , item ) in enumerate (results .items ()):
4733 card_id = str (collect_n ).zfill (pad ) # zero pad for alphanumerical sorting
48- self .cards += [Result (name , item , card_id , self . warn_missing )]
34+ self .cards += [Result (name , item , card_id )]
4935 self .cards = sorted (self .cards , key = lambda i : i .indexes ['status' ], reverse = True )
5036
5137 @cached_property
@@ -66,6 +52,22 @@ def statistics(self):
6652 stats ['skipped' ] += 1
6753 return stats
6854
55+ @cached_property
56+ def image_comparison (self ):
57+ """Whether at least one image comparison test or generation was performed."""
58+ for result in self .cards :
59+ if result .image_status :
60+ return True
61+ return False
62+
63+ @cached_property
64+ def hash_comparison (self ):
65+ """Whether at least one hash comparison test or generation was performed."""
66+ for result in self .cards :
67+ if result .hash_status :
68+ return True
69+ return False
70+
6971
7072class Result :
7173 """
@@ -81,20 +83,14 @@ class Result:
8183 id : str
8284 The test number in order collected. Numbers must be
8385 zero padded due to alphanumerical sorting.
84- warn_missing : dict
85- Whether to include relevant status badges for images and/or hashes.
86- Must have keys ``baseline_image`` and ``baseline_hash``.
8786 """
88- def __init__ (self , name , item , id , warn_missing ):
87+ def __init__ (self , name , item , id ):
8988 # Make the summary dictionary available as attributes
9089 self .__dict__ = item
9190
9291 # Sort index for collection order
9392 self .id = id
9493
95- # Whether to show image and/or hash status badges
96- self .warn_missing = warn_missing
97-
9894 # Name of test with module and test function together and separate
9995 self .full_name = name
10096 self .name = name .split ('.' )[- 1 ]
@@ -154,8 +150,6 @@ def badges(self):
154150 """Additional badges to show beside overall status badge."""
155151 for test_type , status_getter in [('image' , image_status_msg ), ('hash' , hash_status_msg )]:
156152 status = getattr (self , f'{ test_type } _status' )
157- if not self .warn_missing [f'baseline_{ test_type } ' ]:
158- continue # not expected to exist
159153 if (
160154 (status == 'missing' ) or
161155 (self .status == 'failed' and status == 'match' ) or
0 commit comments