Skip to main content

pytest-glow-report

Python pytest License

HTML and JSON test reports for pytest and unittest

Featured in PyCoder’s Weekly #762 (November 24, 2026), under Projects & Code.

Quickstart • Features • Installation • pytest • unittest • Configuration • Test-context API

Quickstart

pip install "pytest-glow-report[pytest]" && pytest

No config is needed. The plugin is on by default and writes reports/report.html, reports/report.json, and reports/history.sqlite.

Features

  • Automatic report generation when the installed pytest plugin is enabled
  • One result per pytest test, including setup, call, and teardown failures
  • A glow-report wrapper for Python's built-in unittest runner
  • HTML and JSON output, plus SQLite-backed history for the last 10 runs in the same report directory
  • Result search and pass/fail/skip filters in the enhanced HTML view
  • Custom report title, environment metadata, and logo hooks for pytest
  • Test steps, logs, and embedded PNG/JPEG screenshots
  • Dark and light themes

Internet access is required for the report styles and interactive controls: Tailwind CSS and Alpine.js are loaded from public CDNs when the report is opened.

Installation

Install the package:

pip install pytest-glow-report

pytest itself is an optional dependency. To install it with the plugin:

pip install "pytest-glow-report[pytest]"

Python 3.10 or newer and pytest 6.0 or newer are supported.

pytest

The plugin is registered through pytest's pytest11 entry point and is enabled by default after installation. Run pytest normally:

pytest

This writes:

reports/
├── report.html
├── report.json
└── history.sqlite

Use another output directory or disable generation for a run:

pytest --report-dir=my_reports
pytest --no-glow-report

--report-dir and --no-glow-report are pytest options; they do not configure the unittest wrapper.

unittest

Run unittest discovery through the installed CLI:

glow-report run -- unittest discover -s tests

The wrapper uses BeautifulTestRunner, preserves unittest's process exit status, and writes to reports/. It records passes, failures, errors, skips, subtests, expected failures, and unexpected successes. Expected failures are represented as skipped results; unexpected successes are represented as failures.

Configuration

Environment variables

The pytest integration reads these variables:

Variable Description Default Example
GLOW_REPORT_TITLE Report header title Glow Test Report My Project CI
GLOW_TEST_TYPE Test-run label — Regression
GLOW_BROWSER Browser label — Chrome 120
GLOW_DEVICE Device or platform label — iPhone 15
GLOW_ENVIRONMENT Target-environment label — Staging
GLOW_BUILD Build or version label — v2.1.0

POSIX shell example:

export GLOW_REPORT_TITLE="E-Commerce Regression"
export GLOW_TEST_TYPE="Regression"
export GLOW_BROWSER="Chrome 120"
export GLOW_ENVIRONMENT="Staging"
pytest

PowerShell example:

$env:GLOW_TEST_TYPE = "Smoke"
$env:GLOW_BROWSER = "Edge 120"
$env:GLOW_DEVICE = "Windows 11"
pytest

pytest customization hooks

Add a logo URL or image data URI in conftest.py:

import pytest


@pytest.hookimpl(optionalhook=True)
def pytest_html_logo():
    return "https://example.com/logo.png"

Add environment metadata:

import os

import pytest


@pytest.hookimpl(optionalhook=True)
def pytest_html_environment():
    return {
        "Browser": "Chrome 120",
        "Environment": os.environ.get("ENV", "local"),
        "Build": os.environ.get("CI_BUILD_ID", "dev"),
        "Branch": os.environ.get("GIT_BRANCH", "main"),
    }

The report always includes the Python version and platform. Hook values are merged into the Environment section.

Test-context API

The context API records data only while a test is running under the pytest plugin or BeautifulTestRunner. Calls made outside an active test still print their console message but are not attached to a report result.

Steps

Use report.step(title) with synchronous or asynchronous functions. The report records the step name, duration, and passed/failed status, then re-raises any exception.

from beautiful_report import report


@report.step("Opening login page")
def open_login(driver):
    driver.get("/login")


@report.step("Loading account")
async def load_account(client):
    return await client.get("/account")

Logs

from beautiful_report import report

report.log("User created successfully")

Screenshots

Attach an existing PNG or JPEG file:

from beautiful_report import report

report.screenshot("login page", path="screenshots/login.png")

Or capture from a synchronous Selenium- or Playwright-style object:

report.screenshot("after submit", driver=driver)

The driver must provide either get_screenshot_as_png() or a synchronous screenshot() method that returns bytes. Screenshots are embedded as data URIs in both report.html and report.json; large screenshots therefore increase both artifact sizes.

Output and history behavior

  • report.html is the human-readable report.
  • report.json contains the same summary, test results, environment metadata, history snapshot, and pytest session exit status when applicable.
  • history.sqlite stores aggregate run counts and duration. The HTML and JSON outputs show up to the 10 most recent rows from that database.
  • Reusing a report directory updates its history. Deleting or changing the directory starts a new history database.
  • Each run replaces report.html and report.json in the selected directory.
  • With pytest-xdist (for example -n 2), only the main pytest process writes the report and history, so each run adds one history entry. Steps, logs and screenshots from every worker appear in that one report.

Generated reports can contain test names, tracebacks, captured output, custom logs, metadata, and screenshots. Treat them as potentially sensitive CI artifacts and review them before sharing.

Development

pip install -e ".[dev]"
pytest tests/
ruff check .
mypy src/
python -m build

See CONTRIBUTING.md for contribution guidelines.

Author

Dhiraj Das · Follow @dkkkkd on X

Learn more

The Automation Architect's Playbook is a free guide. The pytest-glow-report chapter covers turning test results into HTML reports with steps, logs, and screenshots.

License

MIT License. See LICENSE.


  • pytest-glow-report — Zero-config interactive HTML/JSON reports for pytest with SQLite-backed run history.
  • outcomelock — Prevent autonomous AI agents from re-executing already completed work with fail-closed terminal assertions.
  • flow2skill — Compile Playwright codegen recordings into redacted, review-gated agent skills and pytest proofs.

Metadata

Release files for pytest-glow-report 0.1.5

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-glow-report 0.1.5
File Size Uploaded Provenance Actions
pytest_glow_report-0.1.5.tar.gz 38.7 kB With provenance Details for pytest_glow_report-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-glow-report 0.1.5
File Interpreter ABI Platform Actions
pytest_glow_report-0.1.5-py3-none-any.whl Python 3 none any Details for pytest_glow_report-0.1.5-py3-none-any.whl

Total release size: 67.9 kB

Release files / pytest_glow_report-0.1.5.tar.gz

Download URL pytest_glow_report-0.1.5.tar.gz
Size 38.7 kB
Tags Source
SHA-256 checksum
How to use checksums
254f52adaad9406bfab66b74378c311e6f406ebe96bd3997dc788028fa3af34c
BLAKE2b-256 checksum
How to use checksums
6f2aa3848226f5a765408cf146cc94729ffe8b66de8d2c0bd3bc12677764f795
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / pytest_glow_report-0.1.5-py3-none-any.whl

Download URL pytest_glow_report-0.1.5-py3-none-any.whl
Size 29.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45db07b503bef3fe0dd3544d1604bd4e65b33105c0099f19951ac48a21531ed7
BLAKE2b-256 checksum
How to use checksums
18022e30d5ac1284bb764439a1947b9b83ab351ab009f128950ca1fcb5e64186
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for pytest-glow-report 0.1.5

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytest_glow_report-0.1.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

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