pytest-reporter is a Pytest plugin that enables the generation of highly customizable test reports using templates. It provides the data context from a Pytest session, allowing users to create various text-based reports like HTML, LaTeX, or CSV by implementing their own rendering logic. The library is actively maintained with a regular release cadence, often addressing compatibility with new `pytest` versions and enhancing report data.
pip install pytest-reporterVerified import paths — ran on the pinned version, not inferred.
To get started, create a `templates` directory with a Jinja2 HTML template (e.g., `my_report.html`). Then, in your `conftest.py`, implement the `pytest_reporter_render` hook to define how templates are loaded and rendered. Finally, run `pytest` from your project root, specifying the template directory, template file, and output report path using command-line options.
Review and update custom code to remove dependencies on `function_context`. Use other available context objects like `config` or `session.tests`.
Update any custom plugins or `conftest.py` implementations to use `pytest_warning_recorded` instead.
Ensure `jinja2` or your chosen templating engine is installed (`pip install jinja2`) and that `pytest_reporter_render` is correctly implemented in your `conftest.py` to handle template loading and rendering.
Templates should include checks (e.g., `{% if phase.call %}` in Jinja2) before attempting to access `phase.call` to ensure compatibility with `pytest-xdist`.This change primarily affects internal workings. Users experiencing unexpected environment issues post-upgrade should verify their `pytest` and related plugin versions. Ensure compatibility with `pytest`'s own dependency changes.