Python Testing
Priority: P0 (CRITICAL)
Rules
- Use
pytestandpytest-asynciofor async boundaries. - Add regression tests around contract parsing, workflow routing, and verifier outcomes.
- Prefer fakes or monkeypatch at external seams: DB, RPC, Telegram, subprocess, Docker.
- Verify behavior, not implementation trivia.
Recipe
- Write the failing test first for the boundary or regression.
- Patch one seam high enough to keep the test readable.
- Assert structured outcomes: metadata, route result, blocker text, emitted command.
- Use async tests for async code; avoid spinning real event loops manually.
- Cover negative paths for malformed packets, stale runtime state, and missing env.
Anti-Patterns
- No live network or DB in unit tests.
- No broad monkeypatch spray: patch the boundary, not every helper under it.
- No smoke-only proof for shared runtime changes: add focused assertions too.
- No unverified refactor of orchestration code without regression coverage.
References
- Framework Map
- Pytest Patterns