I have a project structure like this:
setup.cfg
integration_tests/
|----tests.py
src/
|----manage.py
|----my_django_app/
And a setup.cfg with this:
[tool:pytest]
addopts=--tb=short --strict -ra
DJANGO_SETTINGS_MODULE = my_django_app.settings
env =
APP_ENV=testing
USE_SQLITE_DB=True
But when I navigate to the top of that directory structure and run pytest
, I get the following:
"pytest-django could not find a Django project (no manage.py file could be found). You must explicitly add your Django project to the Python path to have it picked up."
If I instead navigate to /src/
and run pytest
, the tests run without issue, though obviously since I am down a level none of the inegration tests run.
According to the documentation, it seems like it should drill down from where you run pytest
to attempt to find a manage.py
: https://pytest-django.readthedocs.io/en/latest/managing_python_path.html#automatic-looking-for-of-django-projects
If that isn't the case, then is there some way to configure a setting in setup.cfg to add src/
to the PYTHONPATH? The suggestion in the doc to install src/
in editable mode using pip isn't really tenable in our environment.