Skip to content

Commit 51050de

Browse files
julenblueyed
authored andcommitted
Added test for setting DSM in pytest_configure
Closes pytest-dev#192
1 parent 1e72766 commit 51050de

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_django_settings_module.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,25 @@ def test_ds_after_user_conftest(testdir, monkeypatch):
9696
result.stdout.fnmatch_lines(['*1 passed*'])
9797

9898

99+
def test_ds_in_pytest_configure(testdir, monkeypatch):
100+
monkeypatch.delenv('DJANGO_SETTINGS_MODULE')
101+
pkg = testdir.mkpydir('tpkg')
102+
settings = pkg.join('settings_ds.py')
103+
settings.write(BARE_SETTINGS)
104+
testdir.makeconftest("""
105+
import os
106+
107+
from django.conf import settings
108+
109+
def pytest_configure():
110+
if not settings.configured:
111+
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
112+
'tpkg.settings_ds')
113+
""")
114+
r = testdir.runpytest()
115+
assert r.ret == 0
116+
117+
99118
def test_django_settings_configure(testdir, monkeypatch):
100119
"""
101120
Make sure Django can be configured without setting

0 commit comments

Comments
 (0)