February 2022
Intermediate to advanced
274 pages
6h 28m
English
We’ve moved a fixture out of the test module and into a conftest.py file. We can have conftest.py files at really every level of our test directory. Tests can use any fixture that is in the same test module as a test function, or in a conftest.py file in the same directory, or in any level of parent directory up to the root of the tests.
That brings up a problem if we can’t remember where a particular fixture is located and we want to see the source code. Of course, pytest has our back. Just use --fixtures and we are good to go.
Let’s first try it:
| | $ cd /path/to/code/ch3/a/ |
| | $ pytest --fixtures -v |
| | ... |
| | -------------------- fixtures defined from conftest --------------------- |
| | cards_db ... |
Read now
Unlock full access