pytest-glow-report
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-reportwrapper 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
The HTML includes readable fallback styling for offline use. Tailwind CSS and Alpine.js are loaded from public CDNs for the full styling and interactive experience, so those enhancements require network access 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:
def pytest_html_logo():
return "https://example.com/logo.png"
Add environment metadata:
import os
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.htmlis the human-readable report.report.jsoncontains the same summary, test results, environment metadata, history snapshot, and pytest session exit status when applicable.history.sqlitestores 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.htmlandreport.jsonin 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.
License
MIT License. See LICENSE.
Metadata
Release files for pytest-glow-report 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_glow_report-0.1.3.tar.gz | 30.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_glow_report-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 58.4 kB
Release files / pytest_glow_report-0.1.3.tar.gz
| Download URL | pytest_glow_report-0.1.3.tar.gz |
|---|---|
| Size | 30.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a4502a6af380ef1e9e7b6de2dd43e875911a8767995f8ec03ae62c43eb58607
|
|
BLAKE2b-256 checksum How to use checksums |
3f6a85ffc319f76dae55ac4a49a487b073d29ab5d7414e02290b2b694cdefc1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|
Release files / pytest_glow_report-0.1.3-py3-none-any.whl
| Download URL | pytest_glow_report-0.1.3-py3-none-any.whl |
|---|---|
| Size | 27.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0074d29378af34a74670b4a6838eda8ea3edd80d6a4d6795673e705d53976579
|
|
BLAKE2b-256 checksum How to use checksums |
51a4446ab8b5f6013715cf2b581a851efada42d304b31e44ff1a582f19b9e6da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|