February 2022
Intermediate to advanced
274 pages
6h 28m
English
The conftest.py file is used to store fixtures and hook functions. (Fixtures are described in Chapter 3, pytest Fixtures, and hook functions are discussed in Chapter 15, Building Plugins.) You can have as many conftest.py files as you want in a project, even one per test subdirectory. Anything defined in a conftest.py file applies to tests in that directory and all subdirectories.
If you have one top conftest.py file at the tests level, fixtures defined there can be used with all tests in the top-level tests directory and below. Then if there are specific fixtures that only apply to a subdirectory, they can be defined in another conftest.py file in that subdirectory. For instance, ...
Read now
Unlock full access