testing-py
Installation
SKILL.md
Testing Python
A green suite is not a tested suite. Most Python suites pass while shipping bugs because they lie in four predictable ways, and your job is to refuse each lie:
- Line-only coverage reports 95% while every
elseandexceptarm is unvisited. - Mocks patched at the wrong place never apply, so the test runs the real code or asserts nothing.
- autospec-less mocks pass even when you typo a method name or change a signature — a false green.
- autouse fixtures mutate hidden global state, so tests pass alone and fail in CI order.
The posture, non-negotiable: pytest 9 strict markers and strict config on, branch coverage on, autospec= on every mock, and Hypothesis property tests for any pure logic with an invariant. Assert on behavior, never on a mock's internals.
Versions you are on (2026-06): pytest 9.0.2, coverage.py 7.14.1, pytest-cov 7.x (needs coverage ≥ 7.10.6), Hypothesis 6.155.x.
Which test do I need?
Pick the cheapest test that still catches the bug.