Skip to content

Commit

Permalink
Handle shape mismatch results in HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
ConorMacBride committed Apr 22, 2022
1 parent 39875b7 commit 06475e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pytest_mpl/summary/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def _rms_sort(self):
if self.image_status == 'match':
return "000000"
elif self.image_status == 'diff':
if self.rms is None: # Shape mismatch
return "999999"
# RMS will be in [0, 255]
return f"{(self.rms + 2) * 1000:06.0f}"
else: # Missing baseline image
Expand Down
6 changes: 5 additions & 1 deletion pytest_mpl/summary/templates/result.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
<div class="card">
<a class="btn" data-bs-toggle="offcanvas" href="#offcanvas{{ r.id }}" role="button"
aria-controls="offcanvas{{ r.id }}">
{% if r.diff_image -%}
{% if r.image_status and r.image_status == "diff" -%}
<div class="hover-image">
{% if r.diff_image -%}
<div class="diff-image">
<img src="{{ r.diff_image }}" class="card-img-top" alt="diff image">
</div>
<div class="result-image">
<img src="{{ r.result_image }}" class="card-img-top" alt="result image">
</div>
{%- else -%}
<img src="{{ r.result_image }}" class="card-img-top" alt="result image">
{%- endif %}
</div>
{%- elif r.result_image -%}
<img src="{{ r.result_image }}" class="card-img-top" alt="result image">
Expand Down

0 comments on commit 06475e8

Please sign in to comment.