I recently discovered pytest
. It seems great. However, I feel the documentation could be better.
I’m trying to understand what conftest.py
files are meant to be used for.
In my (currently small) test suite I have one conftest.py
file at the project root. I use it to define the fixtures that I inject into my tests.
I have two questions:
- Is this the correct use of
conftest.py
? Does it have other uses? - Can I have more than one
conftest.py
file? When would I want to do that? Examples will be appreciated.
More generally, how would you define the purpose and correct use of conftest.py
file(s) in a py.test test suite?