@@ -26,26 +26,12 @@ class Results:
26
26
def __init__ (self , results , title = "Image comparison" ):
27
27
self .title = title # HTML <title>
28
28
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
-
43
29
# Generate sorted list of results
44
30
self .cards = []
45
31
pad = len (str (len (results .items ()))) # maximum length of a result index
46
32
for collect_n , (name , item ) in enumerate (results .items ()):
47
33
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 )]
49
35
self .cards = sorted (self .cards , key = lambda i : i .indexes ['status' ], reverse = True )
50
36
51
37
@cached_property
@@ -66,6 +52,22 @@ def statistics(self):
66
52
stats ['skipped' ] += 1
67
53
return stats
68
54
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
+
69
71
70
72
class Result :
71
73
"""
@@ -81,20 +83,14 @@ class Result:
81
83
id : str
82
84
The test number in order collected. Numbers must be
83
85
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``.
87
86
"""
88
- def __init__ (self , name , item , id , warn_missing ):
87
+ def __init__ (self , name , item , id ):
89
88
# Make the summary dictionary available as attributes
90
89
self .__dict__ = item
91
90
92
91
# Sort index for collection order
93
92
self .id = id
94
93
95
- # Whether to show image and/or hash status badges
96
- self .warn_missing = warn_missing
97
-
98
94
# Name of test with module and test function together and separate
99
95
self .full_name = name
100
96
self .name = name .split ('.' )[- 1 ]
@@ -154,8 +150,6 @@ def badges(self):
154
150
"""Additional badges to show beside overall status badge."""
155
151
for test_type , status_getter in [('image' , image_status_msg ), ('hash' , hash_status_msg )]:
156
152
status = getattr (self , f'{ test_type } _status' )
157
- if not self .warn_missing [f'baseline_{ test_type } ' ]:
158
- continue # not expected to exist
159
153
if (
160
154
(status == 'missing' ) or
161
155
(self .status == 'failed' and status == 'match' ) or
0 commit comments