Skip to content

Commit d7e0190

Browse files
committed
Pre-sort on status
Signed-off-by: Conor MacBride <[email protected]>
1 parent 06fce93 commit d7e0190

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pytest_mpl/summary/html.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def template(name):
4141
RESULT_IMAGES = template('result_images')
4242

4343

44-
def status_sort(status):
44+
def get_status_sort(status):
4545
s = 50
4646
if status['overall'] == 'failed':
4747
s -= 10
@@ -119,6 +119,7 @@ def card(name, item, warn_missing=None):
119119
module = '.'.join(name.split('.')[:-1])
120120

121121
status, classes, badge = get_status(item, card_id, warn_missing)
122+
status_sort = get_status_sort(status)
122123

123124
if item['diff_image'] is None:
124125
image = f'<img src="{item["result_image"]}" class="card-img-top" alt="result image">'
@@ -170,15 +171,15 @@ def card(name, item, warn_missing=None):
170171
id=card_id,
171172
test_name=test_name,
172173
module=module,
173-
status_sort=status_sort(status),
174+
status_sort=status_sort,
174175

175176
image=image,
176177
badge=badge,
177178
offcanvas=offcanvas,
178179

179180
)
180181

181-
return result_card
182+
return result_card, status_sort
182183

183184

184185
def generate_summary_html(results, results_dir):
@@ -196,15 +197,16 @@ def generate_summary_html(results, results_dir):
196197
classes += ['no-hash-test']
197198

198199
# Generate result cards
199-
cards = ''
200+
cards = []
200201
for name, item in results.items():
201-
cards += card(name, item, warn_missing=warn_missing)
202+
cards += [card(name, item, warn_missing=warn_missing)]
203+
cards = [j[0] for j in sorted(cards, key=lambda i: i[1])]
202204

203205
# Generate HTML
204206
html = BASE.format(
205207
title="Image comparison",
206208
navbar=NAVBAR,
207-
cards=cards,
209+
cards="\n".join(cards),
208210
filter=FILTER,
209211
classes=" ".join(classes),
210212
)

0 commit comments

Comments
 (0)