Skip to content

Commit

Permalink
Support pytest-metadata 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
christiansandberg committed Jun 5, 2023
1 parent 661d3d2 commit 74a4a8c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
6 changes: 6 additions & 0 deletions pytest_reporter_html1/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ def pytest_reporter_loader(self, dirs, config):
def pytest_reporter_context(self, context, config):
context.setdefault("colors", COLORS)
context.setdefault("time_format", "%Y-%m-%d %H:%M:%S")
metadata = context.setdefault("metadata", {})

if config.pluginmanager.getplugin("metadata"):
from pytest_metadata.plugin import metadata_key

metadata.update(config.stash[metadata_key])

def _cssfilter(self, css):
if self.self_contained:
Expand Down
30 changes: 14 additions & 16 deletions pytest_reporter_html1/templates/html1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,20 @@ <h1>Summary</h1>
<th>Total run time</th>
<td>{{ tests|map(attribute='phases')|map('sum', 'report.duration')|sum|timedelta }}</td>
</tr>
{% if config._metadata %}
{% for key, value in config._metadata.items() %}
<tr>
<th>{{ key }}</th>
<td>
{% if value is mapping %}
{% for key, value in value.items() %}
{{ key }}: {{ value }}<br>
{% endfor %}
{% else %}
{{ value|urlize }}
{% endif %}
</td>
</tr>
{% endfor %}
{% endif %}
{% for key, value in metadata.items() %}
<tr>
<th>{{ key }}</th>
<td>
{% if value is mapping %}
{% for key, value in value.items() %}
{{ key }}: {{ value }}<br>
{% endfor %}
{% else %}
{{ value|urlize }}
{% endif %}
</td>
</tr>
{% endfor %}
{% endblock %}
</table>
</div>
Expand Down

0 comments on commit 74a4a8c

Please sign in to comment.