February 2022
Intermediate to advanced
274 pages
6h 28m
English
Now that we have two tests using the same fixture, it would be interesting to know exactly in what order everything is getting called.
Fortunately, pytest provides the command-line flag, --setup-show, which shows us the order of operations of tests and fixtures, including the setup and teardown phases of the fixtures:
| | $ cd /path/to/code/ch3 |
| | $ pytest --setup-show test_count.py |
| | ======================== test session starts ========================= |
| | collected 2 items |
| | |
| | test_count.py |
| | SETUP F cards_db |
| | ch3/test_count.py::test_empty (fixtures used: cards_db). |
| | TEARDOWN F cards_db |
| | SETUP F cards_db |
| | ch3/test_count.py::test_two (fixtures used: cards_db). |
| | TEARDOWN F cards_db |
Read now
Unlock full access