Skip to main content

This is a fork of the great template pytest-reporter-html1 with one detail changed: Instead of grouping the tests and showing only a number how many tests have failed and how many have passed, this template tries to mimic the standard pytest output with one dot for every test. This has the advantages that (1) even without expanding a file it’s visible which tests have failed and whether they are the same like in the last run and (2) it gives a better visualization how many tests have failed in a specific file. Hovering over a badge shows the name of the test and it’s status (e.g. passed/failed/skipped).

A basic HTML report for pytest using Jinja2 template engine. Based on pytest-reporter which provides the data to the template.

Features

  • Overview of files, tests, and phases with expandable sections

  • Includes information about tests such as documentation, markers, and fixtures

  • Fairly mobile friendly

  • Complies with Jenkins default CSP policy (with --split-report)

  • Support for pytest-metadata and pytest-rerunfailures

  • May be used as a base template for customization

Screenshot

Installation

You can install “pytest-reporter-html-dots” via pip from PyPI:

$ pip install pytest-reporter-html-dots

Usage

Specify the html-dots template and the output path of the report:

$ pytest --template=html-dots/index.html --report=report.html

By default the report is self-contained, but you can separate CSS, images, and JavaScript by specifying the --split-report option.

Customization

You can customize this template using template inheritance.

If you want to add more information to the meta data table, extend the session_metadata block. Create the following file called report-template.html next to your tox.ini:

{% extends "html-dots/index.html" %}
{% block session_metadata %}
    {{ super() }}
    <tr>
        <th>System under test version</th>
        <td>{{ version }}</td>
    </tr>
{% endblock %}

Add version to the context in the pytest_reporter_context hook in conftest.py:

import pytest

@pytest.hookimpl  # type: ignore [misc]  # Untyped decorator makes function "pytest_reporter_context" untyped
def pytest_reporter_context(context: 'dict[str, object]', config: 'pytest.Config') -> None:
    context['version'] = '0.1.2'

Add --template-dir and change --template in tox.ini (I am using bash to insert a timestamp into the report name via command substitution with date):

[tox]
envlist = py3
isolated_build = True

[testenv]
allowlist_externals = bash
deps =
    mypy
    pytest
    pytest-reporter-html-dots
commands =
    mypy src
    bash -c "pytest --template-dir={toxinidir} --template=report-template.html --report={toxinidir}{/}log{/}pytest-`date +%Y-%m-%d_%H-%M`.html {posargs}"

Some additional filters are available for templates to use:

asset(path_or_content, extension)

Takes a path to a local file or a raw bytes object and either returns a base64 encoded URL or a new relative URL to a copy depending on if the report is self-contained or not.

<img src="{{ 'path/to/image.png'|asset }}">
<img src="{{ raw_byte_data|asset('png') }}">
ansi(s)

Convert ANSI color codes to HTML.

strftime(value, format)

Format a Unix timestamp using datetime.strftime.

Started: {{ started|strftime('%Y-%m-%d %H:%M:%S') }}
timedelta(value)

Convert a time in seconds to a timedelta object.

rst(s)

Convert reStructuredText to HTML.

Metadata

Release files for pytest-reporter-html-dots 0.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-reporter-html-dots 0.11.0
File Size Uploaded
pytest_reporter_html_dots-0.11.0.tar.gz 141.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-reporter-html-dots 0.11.0
File Interpreter ABI Platform
pytest_reporter_html_dots-0.11.0-py3-none-any.whl Python 3 none any Details

Total release size: 159.1 kB

Release files / pytest_reporter_html_dots-0.11.0.tar.gz

Download URL pytest_reporter_html_dots-0.11.0.tar.gz
Size 141.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c1e7db6546496493c4c90e32cd9c4ac685d38fd24c5aea1bfdc9343376e16e8d
BLAKE2b-256 checksum
How to use checksums
bdcdc1bd765a3ed43c7eb085fa4eee514f2ca71e6d04ba5e7bca5089ad6d1f95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3

Release files / pytest_reporter_html_dots-0.11.0-py3-none-any.whl

Download URL pytest_reporter_html_dots-0.11.0-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8260acda2f5f245eec08f5143d8105f9dea4c19d9747c5a1e965a88556da90d6
BLAKE2b-256 checksum
How to use checksums
e5ef451626b5e40dd35948f95423196b04feb2c4d5bea5c912e37497286f6475
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3

Release history Release notifications | RSS feed

This release

0.11.0 This release

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page