NS-017
documentedsilent-non-registration
A test that does not match the discovery pattern is neither run nor reported
- reads as
- pytest exits 0 with a green summary after a new test is added. Conclusion drawn: the new test passes.
- actually
- Collection matches `test_*.py` or `*_test.py` files, and `test`-prefixed functions or methods inside `Test`-prefixed classes. A file named `tests_auth.py`, or a function named `check_expiry`, is never collected. The green result belongs entirely to the other tests. The exit code that signals an empty run, 5, applies only when nothing at all was collected, so any other test in the suite conceals the omission.
- blind because
- An uncollected test produces no pass line and no fail line. The summary counts what ran; it has no term for what was skipped by never being seen.
- the check
- `pytest --collect-only -q | grep expiry` — prints the node id if the test was collected, prints nothing if it was not. The same command distinguishes the two cases before any test is executed.
- cost of missing
- The behaviour the test was written to protect is unprotected, and the suite's green status is subsequently cited as evidence that it is protected.
- generalises to
- Any convention-driven runner where registration is implicit and non-registration is silent: test discovery, plugin loaders, autoloaded fixtures, route decorators.
- source
- docs.pytest.org