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

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
--- PASS  test_user_login                                  0.8ms
--- PASS  test_token_refresh                               1.2ms
Failing assertions — inline, never deferred
--- FAIL  test_fail_int_equality                           0.4ms
  E  assert 3 == 30

--- FAIL  test_fail_string                                 0.6ms
  E  AssertionError: assert 'INTGPT-109' == 'INTGPT-1091'
  E  - INTGPT-1091
  E  + INTGPT-109

--- FAIL  test_fail_none_check                             0.3ms
  E  assert None is not None

--- FAIL  test_fail_bool                                   0.3ms
  E  AssertionError: this flag should be True
  E  assert False
Dict and list diffs
--- FAIL  test_fail_dict                                   0.6ms
  E  AssertionError: assert {'a': 1, 'b': 2, 'c': 3} == {'a': 1, 'b': 999, 'd': 4}
  E  Differing items:
  E  {'b': 2} != {'b': 999}
  E  Left contains 1 more item:
  E  {'c': 3}

--- FAIL  test_fail_list                                   0.5ms
  E  AssertionError: assert ['Global Launch'] == ['Global Launches']
  E  At index 0 diff: 'Global Launch' != 'Global Launches'
Approximate equality (pytest.approx)
--- FAIL  test_fail_approx_abs                             0.2ms
  E  assert 3.141592653589793 == 3.14 ± 0.001
  E  comparison failed
  E  Obtained: 3.141592653589793
  E  Expected: 3.14 ± 0.001

--- FAIL  test_fail_approx_list                            0.2ms
  E  assert [0.3000000000...003] == approx([0.4 ± 1.0e-09])
  E  comparison failed. Mismatched elements: 2 / 2:
  E  Index | Obtained            | Expected
  E  0     | 0.30000000000000004 | 0.4 ± 1.0e-09
  E  1     | 3.3000000000000003  | 3.4 ± 1.0e-09
Skips, xfail, and xpass
--- SKIP   test_skip_platform_conditional                  0.2ms
  E  Skipped: Windows-only feature

--- XFAIL  test_xfail_expected_failure                     0.3ms
  E  xfailed: known bug — assert will fail as expected

--- XPASS  test_xpass_unexpected_pass                      0.2ms
  E  xpassed: this test unexpectedly passes

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
--- PASS   test_error_in_fixture_teardown                  0.2ms
--- ERROR  test_error_in_fixture_teardown                  0.3ms
  E  RuntimeError: Teardown exploded intentionally

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)
--- FAIL  test_fail_with_stdout_and_stderr                 0.4ms
  E  AssertionError: intentional failure with stdout and stderr
  E  assert False
  ── Captured stdout call ──
  stdout payload for this failure
  ── Captured stderr call ──
  stderr payload for this failure

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

Per-file summaries
tests/test_entities.py
  --- PASS  test_user_create                               0.3ms
  --- FAIL  test_user_update                               0.8ms
    E  assert 'inactive' == 'active'
  --- PASS  test_user_delete                               0.2ms
  => 2 passed, 1 failed

tests/test_auth.py
  --- PASS  test_login                                     0.4ms
  --- PASS  test_logout                                    0.3ms
  => 2 passed

Total: 4 passed, 1 failed  in 0.42s

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-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.1.1.tar.gz (36.3 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.1.1-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pytest_glaze-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6fea0a72ce4a7b560d4dbf2256fab9db29afeb37c76e77008ce2c70f7ae11f66
MD5 03ccbfa944693007a327a1f47c37e047
BLAKE2b-256 f0b8725371e077b90295589c1e1c7432c46c009d6d48788f58ca6f8fc8af8dcd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_glaze-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 507455b992a97da2d946bff9a95f76c1b465df0a6cc7d5d19174e8f24ee40c5b
MD5 03c346ecb12df3232724dc451a182f5d
BLAKE2b-256 865519ffe01e11e9662c435a722e6f53f28f073f538a181a251b34b3b945914b

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