I would like to integrate pytest into my workflow. I made a following folder structure:
myproject
├── venv
└── src
├── __init__.py
├── foo
│ ├── __init__.py
│ └── bar.py
└── tests
├── __init__.py
└── test_bar.py
I would like to be able to import the namespace from the foo
package so that I can write test scripts in the tests
folder. Whenever I try to run pytest
, or pytest --import-mode append
I always get the following error:
ModuleNotFoundError: No module named 'foo'
I found this similar question here but adding the __init__.py
files to the tests
and the src
folder does not solve the issue.
Does this have to do with the PYTHONPATH system variable? This folder structure works perfectly if I run the __main__.py
from the src
folder, but fails when I want to use pytest
. Is there a way to do this without having to mess with PYTHONPATH or are there automated ways to edit the system variable?