From 55815c017e7a42a52107c86a0a7e16949046af3f Mon Sep 17 00:00:00 2001 From: Christian Sandberg Date: Fri, 28 Jun 2024 11:20:48 +0200 Subject: [PATCH] Warnings improvements Rename block from warning to warnings Move block inside warnings section Styling improvements --- .../templates/html1/index.html | 18 ++++++++++-------- .../templates/html1/style.css | 13 ++++++------- tests/samples/sample_warning.py | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/pytest_reporter_html1/templates/html1/index.html b/pytest_reporter_html1/templates/html1/index.html index 1b239bf..c84115e 100644 --- a/pytest_reporter_html1/templates/html1/index.html +++ b/pytest_reporter_html1/templates/html1/index.html @@ -98,8 +98,8 @@

Summary

{% if warnings %} - {% block warning %}
+ {% block warnings %}

Warnings

@@ -107,10 +107,9 @@

Warnings

- WARNINGS + Warnings - + {{ warnings|count }} @@ -120,9 +119,12 @@

    {% for warning in warnings %}
  • -

    {{ warning.category | replace("", "") }} - {{ warning.filename }}:{{ warning.lineno }}

    -

    {{ warning.message }}

    + {{ warning.category.__name__ }} + + {{ warning.message }} +
    + {{ warning.filename }}:{{ warning.lineno }} +
  • {% endfor %}
@@ -130,8 +132,8 @@

-
{% endblock %} + {% endif %}
diff --git a/pytest_reporter_html1/templates/html1/style.css b/pytest_reporter_html1/templates/html1/style.css index 495c7f5..b9bda42 100644 --- a/pytest_reporter_html1/templates/html1/style.css +++ b/pytest_reporter_html1/templates/html1/style.css @@ -227,7 +227,8 @@ header { WARNINGS **********************************************/ -#warnings > .container { +#warnings ul { + padding: 0; display: grid; grid-template-columns: auto 1fr; grid-gap: 0.75rem; @@ -235,14 +236,12 @@ header { } #warnings li { - margin-bottom: 12px; + display: contents; } -#warnings li p { - margin-top: 0px; - margin-bottom: 2px; - display: flex; - gap: 10px; +#warnings .filename { + font-size: 0.875em; + color: #888888; } /********************************************** diff --git a/tests/samples/sample_warning.py b/tests/samples/sample_warning.py index f13350f..f70fd43 100644 --- a/tests/samples/sample_warning.py +++ b/tests/samples/sample_warning.py @@ -1,6 +1,6 @@ from warnings import warn + def test_warning(): warn("This is a user warning.", UserWarning) warn("This is a deprecation.", DeprecationWarning) -