Skip to main content
Join the chat at https://gitter.im/prashanth-sams/pytest-html-reporter PyPI version https://coveralls.io/repos/github/prashanth-sams/pytest-html-reporter/badge.svg?branch=master Downloads

Generates a light-weight static html report based on pytest framework

pytest-html-reporter

Features

  • Generic information

    • Overview

    • Environment

    • Trends

    • Suite Highlights

    • Test suite details

  • Archives / History

  • Screenshots on failure

  • Test Rerun support

  • Parallel run support (pytest-xdist)

Installation

$ pip3 install pytest-html-reporter

Usage

By default, the filename used is pytest_html_reporter.html and path chosen is report; you can skip both or either one of them if not needed:

$ pytest tests/

Custom path, filename, and title

Add --html-report tag followed by path location and filename to customize the report location and filename:

$ pytest tests/ --html-report=./report
$ pytest tests/ --html-report=./report/report.html

Add --title tag followed by the report title; it is capped at 20 characters and the cut tail fades out, with the full title kept as the heading’s tooltip:

$ pytest tests/ --html-report=./report --title='PYTEST REPORT'

Add --archive-count tag followed by an integer to limit showing the number of builds in the Archives section:

$ pytest tests/ --archive-count 7
$ pytest tests/ --html-report=./report --archive-count 7

Environment and build details

Add --environment tag followed by the environment under test; it shows as a badge beside the report title. The badge is capped at 10 characters and the cut tail fades out, with the full name kept in the Environment panel and in the badge’s tooltip:

$ pytest tests/ --environment=staging

Add --build-info tag followed by key=value to add any other detail to the Environment panel; repeat it as often as you like:

$ pytest tests/ --environment=prod --build-info branch=main --build-info sha=$GITHUB_SHA

pytest.ini

Alternate option is to add this snippet in the pytest.ini file:

[pytest]
addopts = -vs -rf --html-report=./report --title='PYTEST REPORT'
environment = staging
build_info =
    branch=main
    team=payments

Note: --environment overrides the environment ini value; --build-info entries are added to the ones set in the ini file rather than replacing them

Note: If you fail to provide --html-report tag, it consider your project’s home directory as the base

screenshots on failure

Import attach from the library and call it with the selenium command as given below:

from pytest_html_reporter import attach

...
attach(data=self.driver.get_screenshot_as_png())
https://img.shields.io/badge/Attach_screenshot_snippet-000?style=for-the-badge&logo=ko-fi&logoColor=white https://i.imgur.com/1HSYkdC.gif

parallel runs

Runs distributed with pytest-xdist are gathered into a single report. Every worker sends its results back to the controller, which merges them and writes one report - one build in Archives, one set of totals, one row per test - whichever way the tests were distributed:

$ pytest tests/ -n 2 --html-report=./report
$ pytest tests/ -n auto --dist loadfile --html-report=./report

Tests are listed in collection order rather than the order the workers happened to finish them in, so a parallel report reads the same as a serial one. Nothing needs to be configured, and running without -n is unaffected.

Note: results are handed over when a worker finishes, so tests from a worker that crashes outright (rather than failing) are not in the report - pytest reports the crash itself

Is there a demo available for this gem?

Yes, you can use this demo as an example, https://github.com/prashanth-sams/pytest-html-reporter:

$ pytest tests/functional/

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_html_reporter-0.3.2.tar.gz (50.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_html_reporter-0.3.2-py3-none-any.whl (53.2 kB view details)

Uploaded Python 3

File details

Details for the file pytest_html_reporter-0.3.2.tar.gz.

File metadata

  • Download URL: pytest_html_reporter-0.3.2.tar.gz
  • Upload date:
  • Size: 50.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for pytest_html_reporter-0.3.2.tar.gz
Algorithm Hash digest
SHA256 26668d5028a8a16d6d05ebe8304e137fab12b13347ab63447bc7feb11af4ac90
MD5 cf8667fd09dbc34edc1f50a5471329de
BLAKE2b-256 7bb42f89a1dd7468acc3f776e39fa1416a4f526af87e0a2966eba3fcac27a641

See more details on using hashes here.

File details

Details for the file pytest_html_reporter-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_html_reporter-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 64be3e31aaa9ec489ba24a2fa39cd3ee755db96ab59f27dd459074a43598683b
MD5 7f812ac6ec96802e9f12ad264c54e969
BLAKE2b-256 79d4e8f8fa513f1ca76a575d9e5f57e53321fab75b18b13a64d8895a294b735d

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

This release

0.3.2 This release

2 files

0.3.1

2 files

0.3.0

2 files

0.2.9

1 file

0.2.8

1 file

0.2.7

1 file

0.2.6

1 file

0.2.5

1 file

0.2.4

1 file

0.2.3

1 file

0.2.2

1 file

0.2.1

1 file

0.2.0

1 file

0.1.9

1 file

0.1.8

1 file

0.1.7

1 file

0.1.6

1 file

0.1.5

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

0.0.9

1 file

0.0.8

1 file

0.0.7

1 file

0.0.6

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

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