Skip to content

Improve parametrized test names in HTML summaries #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pytest_mpl/summary/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ def __init__(self, name, item, id):

# Name of test with module and test function together and separate
self.full_name = name
self.name = name.split('.')[-1]
self.module = '.'.join(name.split('.')[:-1])
without_parametrized_name = name.split("[")[0]
self.module = ".".join(without_parametrized_name.split(".")[:-1])
self.name = name[len(self.module)+1:]

# Additional classes to add to the result card
self.classes = [f'{k}-{str(v).lower()}' for k, v in [
Expand Down
2 changes: 1 addition & 1 deletion pytest_mpl/summary/templates/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h2>Image test comparison</h2>
{%- endif %}
</td>
{% macro image(file) -%}
<td>{% if file %}<img src="{{ file }}">{% endif %}</td>
<td>{% if file %}<img src="{{ file | urlencode }}">{% endif %}</td>
{%- endmacro -%}
{{ image(result.baseline_image) }}
{{ image(result.diff_image) }}
Expand Down
10 changes: 5 additions & 5 deletions pytest_mpl/summary/templates/result.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
<div class="hover-image">
{% if r.diff_image -%}
<div class="diff-image">
<img src="{{ r.diff_image }}" class="card-img-top" alt="diff image">
<img src="{{ r.diff_image | urlencode }}" class="card-img-top" alt="diff image">
</div>
<div class="result-image">
<img src="{{ r.result_image }}" class="card-img-top" alt="result image">
<img src="{{ r.result_image | urlencode }}" class="card-img-top" alt="result image">
</div>
{%- else -%}
<img src="{{ r.result_image }}" class="card-img-top" alt="result image">
<img src="{{ r.result_image | urlencode }}" 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">
<img src="{{ r.result_image | urlencode }}" class="card-img-top" alt="result image">
{%- elif r.baseline_image -%}
<img src="{{ r.baseline_image }}" class="card-img-top" alt="baseline image">
<img src="{{ r.baseline_image | urlencode }}" class="card-img-top" alt="baseline image">
{%- endif %}
</a>
{% filter indent(width=8) -%}
Expand Down
2 changes: 1 addition & 1 deletion pytest_mpl/summary/templates/result_images.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h5 class="card-title">{{ r.name }}</h5>
<div class="card h-100">
<div class="card-header">{{ name }}</div>
{% if file -%}
<img src="{{ file }}" class="card-img-top" alt="{{ name }}">
<img src="{{ file | urlencode }}" class="card-img-top" alt="{{ name }}">
{%- endif %}
</div>
</div>
Expand Down