Pytest needs to import your code and test modules, and it is up to you how to organize them. Pytest supports two common test layouts, which we will discuss next.
Organizing files and packages
Tests that accompany your code
You can place your test modules together with the code they are testing by creating a tests folder next to the modules themselves:
setup.py
mylib/
tests/
__init__.py
test_core.py
test_utils.py
__init__.py
core.py
utils.py
By putting the tests near the code they test, you gain the following advantages:
- It is easier to add new tests and test modules in this hierarchy and keep them in sync
- Your tests are now part of your package, so they can be deployed and run in other...