Skip to content

Commit 1d0c6e0

Browse files
committed
Call django.setup() in test for invocations via pytest.main()
1 parent e44d099 commit 1d0c6e0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tests/test_django_settings_module.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def test_django_settings_configure(testdir, monkeypatch):
132132
monkeypatch.delenv('DJANGO_SETTINGS_MODULE')
133133

134134
p = testdir.makepyfile(run="""
135+
import django
135136
from django.conf import settings
136137
settings.configure(SECRET_KEY='set from settings.configure()',
137138
DATABASES={'default': {
@@ -141,6 +142,9 @@ def test_django_settings_configure(testdir, monkeypatch):
141142
INSTALLED_APPS=['django.contrib.auth',
142143
'django.contrib.contenttypes',])
143144
145+
if hasattr(django, 'setup'):
146+
django.setup()
147+
144148
import pytest
145149
146150
pytest.main()

0 commit comments

Comments
 (0)