File tree 2 files changed +10
-8
lines changed
2 files changed +10
-8
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 6
6
import django
7
7
import pytest
8
8
9
- from pytest_django .lazy_django import django_settings_is_configured
10
-
11
9
12
10
BARE_SETTINGS = '''
13
11
# At least one database must be configured
@@ -267,17 +265,21 @@ def test_anything():
267
265
result .stdout .fnmatch_lines (['*TEST: populating=False,ready=True*' ])
268
266
269
267
270
- def test_django_settings_is_configured ():
271
- assert django_settings_is_configured () is False
272
-
273
-
274
- def test_no_ds_but_django_imported (testdir ):
268
+ def test_no_ds_but_django_imported (testdir , monkeypatch ):
275
269
"""pytest-django should not bail out, if "django" has been imported
276
270
somewhere, e.g. via pytest-splinter."""
271
+
272
+ monkeypatch .delenv ('DJANGO_SETTINGS_MODULE' )
273
+
277
274
testdir .makepyfile ("""
278
275
import os
279
276
import django
280
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
+
281
283
def test_env():
282
284
assert 'DJANGO_SETTINGS_MODULE' not in os.environ
283
285
You can’t perform that action at this time.
0 commit comments