Skip to main content

A pytest plugin that generates self-contained HTML automation reports with visual charts.

Project description

pytest-automation-report

pytest-automation-report is a lightweight pytest plugin that creates a self-contained HTML execution report after a test run. It works with plain pytest suites as well as UI suites built on Selenium or Playwright. The report includes:

  • summary cards for key test metrics
  • outcome distribution charts
  • execution phase timing charts
  • slowest test visualizations
  • module-level execution breakdown
  • embedded failure screenshots
  • failure details and a complete test result table

Preview

Dashboard summary

Generated from the demo report produced by tests/test_demo_screenshot.py.

Dashboard summary preview

Failure details with screenshots

Failure details preview

Installation

pip install -e .

Usage

Generate a report on demand:

pytest --automation-report=reports/automation-report.html

Customize the report title:

pytest \
  --automation-report=reports/automation-report.html \
  --automation-report-title="Nightly Regression Dashboard"

You can also configure a default output path in pytest.ini:

[pytest]
automation_report = reports/automation-report.html
automation_report_title = CI Automation Report

What the Report Includes

  • KPI summary cards for total tests, pass rate, total runtime, and average runtime
  • a donut chart showing overall test outcomes
  • a bar chart for total phase durations across setup, call, and teardown
  • a bar chart for the slowest tests in the run
  • a bar chart highlighting the busiest test modules
  • embedded screenshots for failed UI tests
  • failure cards with stack traces
  • a detailed test results table

Example Integration

Once installed, the plugin is discovered automatically by pytest through the pytest11 entry point. That means your existing test suite can use it without changing test code.

If you prefer local plugin loading during development, you can also enable it explicitly:

# conftest.py
pytest_plugins = ["pytest_automation_report.plugin"]

UI Screenshot Support

The plugin supports screenshots in two ways:

  • automatic capture on test failure from supported Selenium and Playwright fixtures
  • manual screenshot attachment from the test itself through the automation_report fixture

Automatic failure screenshots

Selenium WebDriver fixtures named driver, browser, selenium, or webdriver are detected automatically when they expose get_screenshot_as_base64() or get_screenshot_as_png().

If your test already uses a Selenium fixture called driver, no extra code is required beyond generating the report:

def test_checkout(driver):
    driver.get("https://example.com/checkout")
    assert "Success" in driver.page_source

When that test fails during the call phase, the plugin will try to capture a screenshot and embed it directly in the HTML report.

Playwright sync fixtures named page, playwright_page, context, or browser_context are also supported. For context fixtures, the plugin captures the most recently opened page.

def test_checkout(page):
    page.goto("https://example.com/checkout")
    assert page.get_by_text("Success").is_visible()

When that test fails during the call phase, the plugin will call page.screenshot(type="png") and embed the image into the report.

Manual screenshot attachment

Use the built-in automation_report fixture when you want explicit control over what gets attached:

def test_checkout(driver, automation_report):
    driver.get("https://example.com/checkout")

    if "Success" not in driver.page_source:
        automation_report(
            image_base64=driver.get_screenshot_as_base64(),
            name="Checkout failure state",
        )

    assert "Success" in driver.page_source

You can also attach raw bytes:

automation_report(image_bytes=driver.get_screenshot_as_png(), name="Current page")

The same manual helper works with Playwright:

def test_checkout(page, automation_report):
    page.goto("https://example.com/checkout")
    automation_report(image_bytes=page.screenshot(type="png"), name="Checkout state")
    assert page.get_by_text("Success").is_visible()

Helper import option

If you prefer not to use the fixture, you can also call the helper directly:

from pytest_automation_report.plugin import attach_screenshot


def test_checkout(driver, request):
    attach_screenshot(
        request,
        image_base64=driver.get_screenshot_as_base64(),
        name="Checkout failure state",
    )

Project details


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_report_builder-0.1.6.tar.gz (18.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_report_builder-0.1.6-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file pytest_html_report_builder-0.1.6.tar.gz.

File metadata

File hashes

Hashes for pytest_html_report_builder-0.1.6.tar.gz
Algorithm Hash digest
SHA256 6426248edd56f1dff981607e4fe493c8b1d1e9b930a3e971346027c6eb942e4c
MD5 2f15195b75e51f674152bc5abf9c4de6
BLAKE2b-256 94875c53da567c5fbf2fccc1761079da2010579bd6ba7bcc39bb8b25a06fb4cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_html_report_builder-0.1.6.tar.gz:

Publisher: publish.yml on viduroberoi/pytest-html-report-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_html_report_builder-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_html_report_builder-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2b4c2cced2a67a4bf09988706ea0aa193d9bb5af900e9262af3f4a8b41b621d4
MD5 e8f20247acb579df4c2f943a8f40cf14
BLAKE2b-256 7aa94f66be128a1ce1217c21abfc98d3aa5eadc1a47384b75a729d42d8d4bfb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_html_report_builder-0.1.6-py3-none-any.whl:

Publisher: publish.yml on viduroberoi/pytest-html-report-builder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page