Senior
In what order will fixtures from conftest and the test file run when the scope is the same, i.e., function?
sobes.tech AI
Answer from AI
With the same scope="function", fixtures from conftest.py and from the test file are run for each test, and the order of their execution is as follows:
- Fixtures from conftest.py are executed first, as they have a more global scope and are imported earlier.
- Then, fixtures defined directly in the test file are executed.
This means that if there are fixtures with the same names in conftest.py and in the test file, the fixtures from the test file can override or supplement the behavior.
This order allows setting common configurations and preparations in conftest.py, and more specific ones in the test file.