pytest-html

4.2.0 · active · verified Wed Apr 01

pytest-html is a plugin for the pytest testing framework that generates comprehensive HTML reports for test results. It provides a visual overview of test runs, including pass/fail status, durations, and detailed information for each test. The library is actively maintained, with version 4.2.0 being the current release, and follows a frequent release cadence, addressing bug fixes and improvements regularly.

Warnings

Install

Imports

Quickstart

Create a test file (e.g., `test_example.py`). Run pytest from your terminal, specifying the `--html` option to define the report filename and `--self-contained-html` to embed all CSS/JS directly into the HTML, making it easier to share.

import pytest

# test_example.py
def test_pass():
    assert True

def test_fail():
    assert False

def test_skipped():
    pytest.skip("This test is skipped")

# To run tests and generate a self-contained HTML report:
# $ pytest --html=report.html --self-contained-html
# (Run this command in your terminal where test_example.py is located)

view raw JSON →