Skip to main content

A thin, transparent coat that makes your test output shine.

Project description

🏺 pytest-glaze

A thin, transparent coat that makes your test output shine.

PyPI version Python pytest License: MIT GitHub


pytest-glaze demo


pytest-glaze is a drop-in pytest output formatter that replaces the default terminal reporter with a compact, color-semantic display. Failures surface inline — no scrolling to a deferred block — and every color carries a consistent meaning across every line type.


Why pytest-glaze?

The default pytest reporter is designed for completeness. pytest-glaze is designed for reading speed. When you are deep in a debugging session the question is always the same: what failed, and what exactly was wrong?

Default reporter pytest-rich / pytest-pretty pytest-glaze
Failures inline ✗ deferred block Partial
Consistent color semantics Partial
Zero extra dependencies ✗ Rich required
Compact — one line per result
Per-file summaries
BDD-aware (pytest-bdd)

Color convention

Every color carries one meaning, applied consistently across every line type:

Badge Color Meaning Where you see it
🟢 Bright green Received ✓ / expected value PASS badge, ---, assert right side, - diff, Expected: label
🔴 Bright red Received ✗ / wrong value / expected failure FAIL · XFAIL badge, ---, assert left side, + diff, Obtained: label
🟡 Yellow Skipped / unexpected pass SKIP · XPASS badge, ---, skip reason
🔴 Standard red Collection / setup errors ERROR badge, ---, collection error messages
🍑 Soft peach Context / prose Exception messages, diff context, E prefix, operator keywords
🔅 Dim Metadata Duration, collection count, Total: line

Installation

pip install pytest-glaze

pytest-glaze registers itself automatically — no configuration required. Install and run.

Requirements

  • Python ≥ 3.10
  • pytest ≥ 7.0

Usage

Automatic

Once installed, pytest-glaze activates for every pytest invocation:

pytest tests/

Makefile (strongly recommended)

A Makefile gives you precise control: glaze on by default, raw output available when you need to debug the formatter itself. This is the recommended setup for any project with a regular test workflow.

PYTHON := python
PYTEST := uv run pytest          # or: python -m pytest
TESTS  := tests/

# Core formatter flags
# -p no:terminal    silence the default reporter
# -p pytest_glaze   load our plugin (PYTHONPATH=. makes it importable)
FMT := -p no:terminal -p pytest_glaze

# Optional pass-through filters
SUITE ?=
CASE  ?=
K     ?=
ARGS  ?=

_PATH  := $(if $(SUITE),$(SUITE),$(TESTS))
_KFLAG := $(if $(K),-k "$(K)",$(if $(CASE),-k "$(CASE)",))

.PHONY: test test-fast test-unit test-raw

## test        Run suite with glaze output.
##             SUITE=, CASE=, K= for filtering. ARGS= for raw pytest flags.
##             Examples:
##               make test
##               make test SUITE=tests/test_entities.py
##               make test CASE=test_return_statuses_dict
##               make test K="sprint and not slow"
test:
	@PYTHONPATH=. $(PYTEST) $(FMT) $(_PATH) $(_KFLAG) $(ARGS)

## test-fast   Stop on first failure (-x). Accepts same filters as `test`.
test-fast:
	@PYTHONPATH=. $(PYTEST) $(FMT) -x $(_PATH) $(_KFLAG) $(ARGS)

## test-unit   Unit tests only — clean pass/fail signal, no intentional failures.
test-unit:
	@PYTHONPATH=. $(PYTEST) $(FMT) tests/test_parsers.py tests/test_colorizer.py tests/test_plugin.py $(_KFLAG) $(ARGS)

## test-raw    Raw default pytest output. Useful for debugging the formatter.
test-raw:
	@$(PYTEST) $(_PATH) $(_KFLAG) $(ARGS)

## help        List all targets.
help:
	@grep -E '^##' Makefile | sed 's/^## /  /'

Disable for a single run

pytest -p no:pytest_glaze tests/

What it formats

Passing tests

pytest-glaze passing tests

Passing tests render as compact single lines — one line per test, grouped by file and class. No noise, no clutter. Pure green signal.

Failing assertions — inline, never deferred

pytest-glaze failing assertions

Assertion failures render immediately below the failing test — no scrolling to a separate deferred block. Received values are red, expected values are green, prose context stays soft peach.

Dict and list diffs

pytest-glaze dict and list diffs

Received values render in red, expected values in green. Diff markers (- expected, + received) follow the same color convention. Prose context lines stay soft peach so the values stand out.

Approximate equality (pytest.approx)

pytest-glaze approximate equality

Obtained renders in red — the wrong value. Expected renders in green — the target. Table column alignment is preserved so list and dict comparisons stay readable.

Skips, xfail, and xpass

pytest-glaze skips xfail and xpass

XFAIL renders in bright red — an expected failure is still a red signal worth tracking. XPASS renders in yellow — an unexpected pass is a surprise worth investigating, but not an error.

Fixture errors

pytest-glaze fixture errors

Setup and teardown errors are classified separately from test failures. A passing test body followed by a teardown ERROR both appear — neither is silently swallowed.

Captured output (shown only on failures)

pytest-glaze captured output

Captured output sections are suppressed on passing tests and rendered inline on failures — no separate output block to hunt for.

Per-file summaries

pytest-glaze per-file summaries

Class-based test grouping

pytest-glaze class grouping

Class names render as section headers. Method names render without the class prefix. Non-class tests render as before — no header, just the test name.

BDD support (pytest-bdd)

pytest-glaze has first-class support for pytest-bdd. Install pytest-bdd alongside pytest-glaze and BDD scenarios render with Feature/Scenario headers, per-step results, and the same color semantics as regular tests.

Requirements

pip install pytest-bdd

Compact mode (default)

By default pytest-glaze renders BDD scenarios in compact mode — one line per scenario. Failures and errors always show full step-by-step output so you can see exactly where things went wrong.

pytest-glaze compact BDD mode

Full step-by-step mode (--bdd-steps)

Pass --bdd-steps to see every step for every scenario:

pytest --glaze --bdd-steps tests/bdd/

pytest-glaze --bdd-steps mode

Supported scenario types

pytest-glaze handles every pytest-bdd scenario type:

Type Rendering
All steps pass Compact PASS line (default) or full steps (--bdd-steps)
Failing assertion in Then Full steps with colored assert X == Y E line
Non-assertion error in When Full steps with ExceptionType: message E line
Error in Given (setup crash) ERROR on the Given step
Step not found ERROR on the missing step, trimmed message
Skipped (@pytest.mark.skip) --- SKIP Scenario: … with reason
Skipped via Gherkin tag (@skip) Same as above via pytest_bdd_apply_tag
Xfail Last step gets --- XFAIL badge
Xpass Last step gets --- XPASS badge
Background steps Dim Background: label before first background step
Scenario Outline One compact/full line per example row
Multiple example tables Each table's rows rendered independently
Docstring arguments Transparent — steps render normally
Datatable arguments Transparent — steps render normally
Teardown failure --- ERROR teardown failed after the scenario line
Unicode scenario/step names Fully supported
Tagged scenarios Tags applied as pytest marks, rendering unaffected
Rule blocks Scenarios inside Rules render identically
Shared steps (conftest) Transparent — steps render normally
Wildcard * keyword Rendered as continuation step
Generic @step decorator Rendered identically to @given/@when/@then

Makefile targets for BDD

BDD_TESTS := tests/bdd/

FILE     ?=   # scope to a single file:  make test-bdd FILE=test_checkout
SCENARIO ?=   # scope to a scenario:     make test-bdd SCENARIO="Guest completes a purchase"

_BDD_PATH  := $(if $(FILE),tests/bdd/$(FILE).py,$(BDD_TESTS))
_BDD_KFLAG := $(if $(SCENARIO),-k "$(SCENARIO)",)

## test-bdd          Compact BDD output (default).
test-bdd:
	@PYTHONPATH=. $(PYTEST) $(FMT) $(_BDD_PATH) $(_BDD_KFLAG) $(ARGS)

## test-bdd-steps    Full step-by-step BDD output.
test-bdd-steps:
	@PYTHONPATH=. $(PYTEST) $(FMT) --bdd-steps $(_BDD_PATH) $(_BDD_KFLAG) $(ARGS)

## test-bdd-gherkin  Native pytest-bdd Gherkin terminal reporter (-v).
test-bdd-gherkin:
	@PYTHONPATH=. $(PYTEST) --gherkin-terminal-reporter -v $(_BDD_PATH) $(_BDD_KFLAG) $(ARGS)

Noise suppression

pytest-glaze automatically suppresses lines that add no value in compact output — before any line is rendered:

  • Omitting N identical items, use -vv to show
  • Use -v to get more diff
  • Full diff:

The meaningful diff lines remain. The noise does not.


Compatibility

pytest-glaze is a pure formatter with no opinion on how you write your tests. It works alongside:

  • pytest-cov — coverage reporting is unaffected
  • pytest-xdist — parallel runs are supported
  • pytest-bdd — full BDD-aware rendering (see above)
  • pytest-mock, pytest-asyncio, and any plugin that doesn't replace the terminal reporter

Note: Any plugin that also replaces the terminal reporter (e.g. pytest-rich) will conflict. Use one formatter at a time.


Contributing

pytest-glaze is a personal project. If you find a failure shape the formatter doesn't handle well, open an issue with the raw pytest output and I'll take a look. Pull requests are welcome.


License

MIT © mikejmz24


pytest-glaze — because your test output deserves a coat of glaze. 🏺

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_glaze-0.2.5.tar.gz (73.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_glaze-0.2.5-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest_glaze-0.2.5.tar.gz.

File metadata

  • Download URL: pytest_glaze-0.2.5.tar.gz
  • Upload date:
  • Size: 73.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.3

File hashes

Hashes for pytest_glaze-0.2.5.tar.gz
Algorithm Hash digest
SHA256 c960b7f8c1a74ec69355aab8e0d0fb2a87b38947b28e65f337c42da807c16b8e
MD5 df38c161378414963a38731da1856978
BLAKE2b-256 0b7eb1ce7cf5d2493c9ac1a249cc02138a0cef82c56c8f181c6e570118fd0268

See more details on using hashes here.

File details

Details for the file pytest_glaze-0.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_glaze-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5067ebe97e438aab31adcb87155c8b90b289c780a3415bd8062494b67220a01b
MD5 d98dd97be070847125c72d56c5eb59e6
BLAKE2b-256 173fc491ba2002771bb6a30b6184e9fd2dc1b2980ad87bbd467606ff6baec7a9

See more details on using hashes here.

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