Skip to main content

pytest-reporter

PyPI version

Generate Pytest reports from templates. You may use one of the available templates on PyPI (like the reference template pytest-reporter-html1), inherit them in your own template to tweak their content and appearence or make your own from scratch.

Anything text based can be generated like HTML, LaTeX, CSV et.c.

Installation

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

$ pip install pytest-reporter

Usage

Specify the template you want to use and the output path of the report:

$ pytest --template-dir=templates --template=report.html --report=report.html

Writing templates

This plugin does not come with built-in support for any template engines, it is up to each template to implement the rendering (or use another template plugin as base). A minimal template may just implement the pytest_reporter_render hook.

This is a very basic Jinja2 template implementation:

from jinja2 import Environment, FileSystemLoader, TemplateNotFound

def pytest_reporter_render(template_name, dirs, context):
    env = Environment(loader=FileSystemLoader(dirs))
    try:
        template = env.get_template(template_name)
    except TemplateNotFound:
        # Don't know about this name, may be provided by some other template
        return
    return template.render(context)

See pytest-reporter-html1 for a full reference implementation.

The template context

The standard context available for all templates include the following:

  • config: Config

  • session: Session

  • started: Unix timestamp when session started

  • ended: Unix timestamp when session was finished

  • warnings[]: List of warnings.WarningMessage

  • items: Dictionary of collected items with nodeid as keys

  • tests[]: List of each test run as dictionaries with the following keys:

    • item: Item

    • phases[]: List of each test phase (setup, call, teardown) as dictionaries with the following keys:

      • call (optional): CallInfo if available.

      • report: TestReport

      • sections: Same as report.sections but only the sections captured for this phase

      • log_records[]: List of logging.LogRecord recorded during the test phase

      • status: Status of this phase. Dictionary with the following keys:

        • category: Category of the status (e.g. "passed") or empty string

        • letter: Single letter version of status (e.g. "P") or empty string

        • word: Uppercase word version of status (e.g. "PASSED") or empty string

        • style: Dictionary with e.g. {"yellow": True} or empty dictionary

    • status: Status of whole test. Dictionary with the following keys:

      • category: Category of the test status (e.g. "passed")

      • letter: Single letter version of test status (e.g. "P")

      • word: Uppercase word version of test status (e.g. "PASSED")

      • style: Dictionary with e.g. {"yellow": True} or empty dictionary

The context may be extended or modified using the following methods:

  • config.template_context

  • The template_context fixture

  • The pytest_reporter_context() hook

Hooks

See hooks.py for a complete list of hooks available.

License

Distributed under the terms of the MIT license, “pytest-reporter” is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

Metadata

Release files for pytest-reporter 0.5.3

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 0.5.3
File Size Uploaded Provenance Actions
pytest-reporter-0.5.3.tar.gz 9.8 kB Without provenance Details for pytest-reporter-0.5.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-reporter 0.5.3
File Interpreter ABI Platform Actions
pytest_reporter-0.5.3-py3-none-any.whl Python 3 none any Details for pytest_reporter-0.5.3-py3-none-any.whl

Total release size: 17.4 kB

Release files / pytest-reporter-0.5.3.tar.gz

Download URL pytest-reporter-0.5.3.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
426ae38f3c5304659635eff1d4080c8acf4dc6cd833469caed427a9a80bb41aa
BLAKE2b-256 checksum
How to use checksums
0a1aa5f46dd3b78dc207de5813342b3e51207d1bcae92207443536d0f6df24e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.5

Release files / pytest_reporter-0.5.3-py3-none-any.whl

Download URL pytest_reporter-0.5.3-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa39fef46b1926b6f181c2759da0bcfd26b7697ef59d3c5cd260106c59b3a196
BLAKE2b-256 checksum
How to use checksums
e3762bac8243221186d8e8825912b95b04b3110c14f2cb4da6fbc476736e81e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.5

Security for pytest-reporter 0.5.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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