pytest-dev / pytest-django

A Django plugin for pytest.
https://pytest-django.readthedocs.io/
Other
1.37k stars 344 forks source link

Installing pytest-django breaks existing (non-django) tests #1003

Closed 1ace closed 2 years ago

1ace commented 2 years ago

I have tests that have nothing to do with django, and tests in the django folder.

Installing pytest-django breaks running pytest in the non-django tests folders:

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.

Is there an environment variable or something that I can set to only load pytest-django when its assumptions happen to match reality?

1ace commented 2 years ago

Apologies, I think I misdiagnosed the issue; closing it for now, I'll re-open with additional details in case it turns out the breakage is still related to pytest-django :)

1ace commented 2 years ago

For anyone else who might stumble upon this, this issue was that I had DJANGO_SETTINGS_MODULE defined globally; setting it to an empty string (because annoyingly I can't unset variables in the GitLab CI) fixed the issue :)