Orchestrata Ultimate › Gates › test-purity

Gate: test-purity

At a glance

Purpose Refuse mocks, stubs, fakes, monkeypatch and skips in tests/, and a banned-library import anywhere in tests/, src/ or scripts/.
Where it runs The scripts/gates.py battery (registered as test-purity), the suite preflight _run_gates() in scripts/run_tests.py, and scripts/health_check.py.
Trigger A battery run whose fingerprint changed; every suite run's preflight; a health check.
Exact command Battery: python scripts/audit_test_purity.py tests/ --banned-import-only src/ scripts/. Preflight: python scripts/audit_test_purity.py (no arguments; defaults to tests/).
Blocks Exit 1 when any violation is found; 0 clean. No waiver flag.
Ruling / ADR RUL-002 — no mocks, stubs, fakes, skips or monkeypatch; preflight blocking per the user ruling of 2026-07-10 quoted in _run_gates().
Last recorded verdict ok: true in the primary checkout's .cache/gates.json (file last written 2026-09-22 10:01 local). wt-MAP-PRECOMMIT has no .cache/gates.json.

What it refuses

A test that uses a mock, stub, fake, monkeypatch or skip instead of real infrastructure — and, in a separate sweep, an import of a banned library (fakeredis, pyswip, unittest.mock, xdist, …) anywhere in src/, scripts/, or tests/.

Why it exists

The module docstring is operational: "Audit test suite for forbidden patterns: mocks, stubs, fakes, monkeypatch, skips. Scans tests/ directory and reports every file that uses forbidden patterns." The doctrine behind it is RUL-002 / the repo-wide "no mocking — real implementations only" law (CLAUDE.md Key Rules); the gates.py registry comment states the scoping decision:

"test-purity's positional paths scope is tests/ ONLY — mock/stub/monkeypatch/skip are RUL-002 test-purity categories (real infra, no doubles) that do not generalize to production code … banned_import is different in kind: an import of a banned library … is an architecture violation wherever it appears, so --banned-import-only sweeps src/ and scripts/ for that ONE category, closing the gap where such an import outside tests/ was invisible to this gate entirely."

The banned-name set is read through the ONE canonical parser (core.banned_libraries), never a second copy — the script's own comment records why: "A hardcoded second parser is the exact defect that module's own docstring documents twice already … this checker is not adding a third."

How it runs

Typical failures and how to fix them

Wiring