I'm trying to write integration tests with pybuilder on a Django web application, but I can't seem to make it work. An example error which occurs (from within the Django application):
django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
DJANGO_SETTINGS_MODULE
is defined in build.py
, like so:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")
The project is stored in src/main/python
and integration tests are in src/integrationtest/python
, like pybuilder's docs say it should be.
I've tried to manually set DJANGO_SETTINGS_MODULE
in a lot of different places, including build.py
and the test case itself. The same applies for settings.configure()
. But it simply doesn't want to work and I don't know what I'm missing. I've ran out of ideas what to try.