File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ def skip_if_no_django():
17
17
def django_settings_is_configured ():
18
18
# Avoid importing Django if it has not yet been imported
19
19
if not os .environ .get ('DJANGO_SETTINGS_MODULE' ) \
20
- and 'django' not in sys .modules :
20
+ and 'django.conf ' not in sys .modules :
21
21
return False
22
22
23
23
# If DJANGO_SETTINGS_MODULE is defined at this point, Django is assumed to
Original file line number Diff line number Diff line change @@ -263,3 +263,28 @@ def test_anything():
263
263
result .stdout .fnmatch_lines (['*IMPORT: populating=True,ready=False*' ])
264
264
result .stdout .fnmatch_lines (['*READY(): populating=True*' ])
265
265
result .stdout .fnmatch_lines (['*TEST: populating=False,ready=True*' ])
266
+
267
+
268
+ def test_no_ds_but_django_imported (testdir , monkeypatch ):
269
+ """pytest-django should not bail out, if "django" has been imported
270
+ somewhere, e.g. via pytest-splinter."""
271
+
272
+ monkeypatch .delenv ('DJANGO_SETTINGS_MODULE' )
273
+
274
+ testdir .makepyfile ("""
275
+ import os
276
+ import django
277
+
278
+ from pytest_django.lazy_django import django_settings_is_configured
279
+
280
+ def test_django_settings_is_configured():
281
+ assert django_settings_is_configured() is False
282
+
283
+ def test_env():
284
+ assert 'DJANGO_SETTINGS_MODULE' not in os.environ
285
+
286
+ def test_cfg(pytestconfig):
287
+ assert pytestconfig.option.ds is None
288
+ """ )
289
+ r = testdir .runpytest ('-s' )
290
+ assert r .ret == 0
You can’t perform that action at this time.
0 commit comments