August 2018
Beginner
160 pages
4h 8m
English
Pytest always remembers tests that failed in previous sessions, and can reuse that information to skip right to the tests that have failed previously. This is excellent news if you are incrementally fixing a test suite after a large refactoring, as mentioned in the previous section.
You can run the tests that failed before by passing the --lf flag (meaning last failed):
λ pytest --lf tests/core...collected 6 items / 4 deselectedrun-last-failure: rerun previous 2 failures
When used together with -x (--maxfail=1) these two flags are refactoring heaven:
λ pytest -x --lf
This lets you start executing the full suite and then pytest stops at the first test that fails. You fix the code, and execute the same ...
Read now
Unlock full access