Skip to content

v0.12.0 — extension seams for wrappers & plugins

Choose a tag to compare

@prostomarkeloff prostomarkeloff released this 14 Jul 15:33
· 25 commits to main since this release
6069b5f

Extension seams — wrappers & plugins are first-class

Building tooling on top of pytest-fast (run-analysis gates, custom reporters, per-test metrics)
previously meant either the heavy full-report streaming client plus private-API imports, or forking
the renderer. 0.12.0 adds three extension seams, one per process role — each using the mechanism
native to where it runs. See the new README section «Extending pytest-fast» for worked examples.

Worker seam — custom per-test measurements on the bus

New hookspec pytest_fast_annotate_result(item, result, extra) — an ordinary pytest hook: conftest
impls already execute inside forked workers (the full pytest protocol runs there), so you measure
with standard hooks/hookwrappers/fixtures and harvest into extra. Whatever you put there rides the
existing worker→master bus as result["extra"], next to duration/cpu. A raising impl degrades to
a stderr note in the daemon log — never a failed test, never an untrusted run.

Per-test CPU time is now a documented stable field: every standard-loop run ships result["cpu"]
(duration − cpu ≈ I/O wait) — the contention-robust signal for timing analysis.

Daemon seam — summary sections inside the box

PYTEST_FAST_DAEMON_PLUGINS=pkg.mod (comma-separated import paths) names plain modules — the
daemon holds every run's aggregated data but, by architecture, no pytest session (collection lives in
the forkserver preload). Each module exposes pytest_fast_run_completed(run_info); returned lines
are spliced INSIDE the summary box, right before the closing rule — how a timing gate or flakiness
tracker "edits" the pretty output without touching pytest-fast. run_info carries results,
worker_stats, bus, total, warmup, run_wall, num_workers, start_method, label.

Failure policy: import error / missing symbol / raising plugin → a visible ⚠ line in the summary —
never a crashed daemon, never a silently-missing gate. The env var participates in the staleness
fingerprint, so changing the plugin list respawns the warm daemon on its own.

Client seam — wrapper clients with full data access

request_run(address, want_results=True) → the final frame also carries results (lean projection:
nodeid/outcome/duration/cpu/extra/longrepr — the heavy per-phase reports are never re-shipped),
worker_stats and run_meta ({total, warmup, run_wall, num_workers, start_method}). ~100 bytes per
test on the wire — full data access without the full-report bus cost.

The flag rides as the 8th positional element of the run-request tuple: compatible in both
directions
(an older daemon ignores trailing elements; an older client is unaffected). Reply frames
are dicts — treat unknown keys as optional; that's the protocol's forward-compat contract.

run_via_daemon is promoted to public API: the ensure/stale-respawn orchestration the CLI and the
--fast plugin use themselves — compose it with request_run(...) / request_run_streamed(...) and
your wrapper gets daemon lifecycle handling for free.

Verification

New e2e suite tests/test_plugin_seams.py: annotate → bus → daemon plugin → box splice (cpu
presence asserted), all three daemon-plugin degradation paths, want_results frame shape against a
resident daemon + plain-frame invariance without the flag. Full gates: make lint-heavy,
make test-full (104 passed), make test-stress (107 passed — the wire changed, so the fuzz/stress
tier was run).