pytest -k
The pytest option that runs only tests whose names match a substring or a small expression using and, or and not.
In more detail
Good test names make it powerful: pytest -k full_discount runs everything about full discounts. Tests that do not match are reported as deselected, not as skipped or passed.
Example
pytest -q -k full_discountRelated terms
- test naming — Choosing test function names that state the behaviour and the condition, so a failure summary reads as a sentence.
- deselected — The count pytest reports for tests that were collected but left out of this run by a -k or -m selection.
- 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