test collection
The step where pytest searches files and names to decide which tests exist before running any of them.
In more detail
By default pytest collects files named test_*.py or *_test.py, functions whose names start with test at module level, and classes named Test* with no __init__. Anything else is imported but never run, so a misnamed test silently disappears; watch the collected count in the header.
Related terms
- pytest — A popular Python testing framework that finds test functions automatically and reports failures with detailed comparisons.
- --collect-only — A pytest option that lists every test it would run without running any of them.
- node ID — The full address pytest gives each test, made of the file path, two colons and the test name, such as test_discount.py::test_a_silly_percentage_is_refused.
Taught in
- Introducing pytest — Automated Testing, TDD & Quality Engineering
- Naming Tests For Readability — Automated Testing, TDD & Quality Engineering