Skip to content

v0.11.0 — opt-in --persist-workers

Choose a tag to compare

@prostomarkeloff prostomarkeloff released this 12 Jul 22:56
· 28 commits to main since this release
bbc3a76

opt-in --persist-workers — amortize expensive session-scoped fixtures

By default every run forks fresh workers that exit on completion, so a scope="session" fixture (a DB
engine + schema seed, an app factory, a warmed cache) is set up again on every run — the forkserver
amortizes collect, not fixtures. Many-small-runs clients (a mutation tester issuing one run per
mutant, a fuzz loop, a watch-driven re-runner) re-pay that setup every time, and it dominates wall-clock.

--persist-workers holds a warm worker pool across runs/requests: each worker is forked once and its
pytest session spans every run, so session-scoped fixtures are set up once and reused. Works in both
front-ends — local --runs N and the resident --serve daemon (the many-small-runs path).

Opt-in — it trades away cross-run isolation (arbitrary global state a test mutates persists to the
next run). Isolation within a run is unchanged: function- and module-scoped fixtures still tear down
normally between items.

Correctness: re-running an item requires the run-boundary nextitem to differ from the item being
torn down (else pytest keeps its function-scoped fixtures and the re-run can't re-inject them) — handled
via a session-sharing anchor, regression-tested with --workers 2. Serve-mode verdicts are asserted to
match the default per-run-fork path (every item runs, failures propagate, stable across warm requests).

Full CI matrix green — Linux / macOS / Windows × py3.11–3.14, plus lint, parity, and stress. See #9.