@@ -278,7 +278,7 @@ def test_settings():
278278 assert result .ret == 0
279279
280280
281- def test_debug_false (testdir , monkeypatch ):
281+ def test_debug_false_by_default (testdir , monkeypatch ):
282282 monkeypatch .delenv ("DJANGO_SETTINGS_MODULE" )
283283 testdir .makeconftest (
284284 """
@@ -307,6 +307,78 @@ def test_debug_is_false():
307307 assert r .ret == 0
308308
309309
310+ @pytest .mark .parametrize ('django_debug_mode' , (False , True ))
311+ def test_django_debug_mode_true_false (testdir , monkeypatch , django_debug_mode ):
312+ monkeypatch .delenv ("DJANGO_SETTINGS_MODULE" )
313+ testdir .makeini (
314+ """
315+ [pytest]
316+ django_debug_mode = {}
317+ """ .format (django_debug_mode )
318+ )
319+ testdir .makeconftest (
320+ """
321+ from django.conf import settings
322+
323+ def pytest_configure():
324+ settings.configure(SECRET_KEY='set from pytest_configure',
325+ DEBUG=%s,
326+ DATABASES={'default': {
327+ 'ENGINE': 'django.db.backends.sqlite3',
328+ 'NAME': ':memory:'}},
329+ INSTALLED_APPS=['django.contrib.auth',
330+ 'django.contrib.contenttypes',])
331+ """ % (not django_debug_mode )
332+ )
333+
334+ testdir .makepyfile (
335+ """
336+ from django.conf import settings
337+ def test_debug_is_false():
338+ assert settings.DEBUG is {}
339+ """ .format (django_debug_mode )
340+ )
341+
342+ r = testdir .runpytest_subprocess ()
343+ assert r .ret == 0
344+
345+
346+ @pytest .mark .parametrize ('settings_debug' , (False , True ))
347+ def test_django_debug_mode_keep (testdir , monkeypatch , settings_debug ):
348+ monkeypatch .delenv ("DJANGO_SETTINGS_MODULE" )
349+ testdir .makeini (
350+ """
351+ [pytest]
352+ django_debug_mode = keep
353+ """
354+ )
355+ testdir .makeconftest (
356+ """
357+ from django.conf import settings
358+
359+ def pytest_configure():
360+ settings.configure(SECRET_KEY='set from pytest_configure',
361+ DEBUG=%s,
362+ DATABASES={'default': {
363+ 'ENGINE': 'django.db.backends.sqlite3',
364+ 'NAME': ':memory:'}},
365+ INSTALLED_APPS=['django.contrib.auth',
366+ 'django.contrib.contenttypes',])
367+ """ % settings_debug
368+ )
369+
370+ testdir .makepyfile (
371+ """
372+ from django.conf import settings
373+ def test_debug_is_false():
374+ assert settings.DEBUG is {}
375+ """ .format (settings_debug )
376+ )
377+
378+ r = testdir .runpytest_subprocess ()
379+ assert r .ret == 0
380+
381+
310382@pytest .mark .django_project (
311383 extra_settings = """
312384 INSTALLED_APPS = [
0 commit comments