Skip to content

Commit

Permalink
Merge pull request #25 from christiansandberg/warnings-improvements
Browse files Browse the repository at this point in the history
Rename block from warning to warnings
Move block inside warnings section
Styling improvements
  • Loading branch information
christiansandberg committed Jun 28, 2024
2 parents 5776096 + 55815c0 commit fbee872
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
18 changes: 10 additions & 8 deletions pytest_reporter_html1/templates/html1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,18 @@ <h1>Summary</h1>
</section>

{% if warnings %}
{% block warning %}
<section id="warnings">
{% block warnings %}
<div class="container">
<h1>Warnings</h1>

<details class="file">

<summary>
<h2 class="title file-title">
<span class="fspath"> WARNINGS </span>
<span class="fspath">Warnings</span>
<span class="counts">
<span title="{{ warnings|count }}"
class="status badge warning">
<span class="status badge warning">
{{ warnings|count }}
</span>
</span>
Expand All @@ -120,18 +119,21 @@ <h2 class="title file-title">
<ul>
{% for warning in warnings %}
<li>
<p><span class="status badge warning">{{ warning.category | replace("<class '", "") | replace("'>", "") }}</span>
<span>{{ warning.filename }}:{{ warning.lineno }}</span></p>
<p>{{ warning.message }}</p>
<span class="status badge warning">{{ warning.category.__name__ }}</span>
<span>
<span>{{ warning.message }}</span>
<br>
<span class="filename">{{ warning.filename }}:{{ warning.lineno }}</span>
</span>
</li>
{% endfor %}
</ul>

</details>

</div>
</section>
{% endblock %}
</section>
{% endif %}

<section id="test-files">
Expand Down
13 changes: 6 additions & 7 deletions pytest_reporter_html1/templates/html1/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -227,22 +227,21 @@ header {
WARNINGS
**********************************************/

#warnings > .container {
#warnings ul {
padding: 0;
display: grid;
grid-template-columns: auto 1fr;
grid-gap: 0.75rem;
align-items: start;
}

#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;
}

/**********************************************
Expand Down
2 changes: 1 addition & 1 deletion tests/samples/sample_warning.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from warnings import warn


def test_warning():
warn("This is a user warning.", UserWarning)
warn("This is a deprecation.", DeprecationWarning)

0 comments on commit fbee872

Please sign in to comment.