Skip to main content

pytest-glow-report

Python pytest License

HTML and JSON test reports for pytest and unittest

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

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.8 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.

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

License

MIT License. See LICENSE.

Metadata

Release files for pytest-glow-report 0.1.4

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.4
File Size Uploaded Provenance
pytest_glow_report-0.1.4.tar.gz 37.0 kB With provenance Details

Built distribution (wheel)

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

Total release size: 65.5 kB

Release files / pytest_glow_report-0.1.4.tar.gz

Download URL pytest_glow_report-0.1.4.tar.gz
Size 37.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4f466b0a9199e52fa7b1928a65439a00db04a9a44283fe24c6f20bda65909a8c
BLAKE2b-256 checksum
How to use checksums
92269f8921990f013ff02b973bde491c999337775bfdd25e3b18f13f85fdcba3
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 Oct 25, 2026.

Transparency log

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

Download URL pytest_glow_report-0.1.4-py3-none-any.whl
Size 28.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
da74a856c4972403bf1767e7e288933cdc1b48f6e0983e8234c4bd5021b1619b
BLAKE2b-256 checksum
How to use checksums
5f511dc6a0db0195505a49a5e6c104ed938d17be02a944831d376283cd4855b8
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 Oct 25, 2026.

Transparency log

Security for pytest-glow-report 0.1.4

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytest_glow_report-0.1.4.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 Oct 25, 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