Skip to content

Commit 9103942

Browse files
committed
fixup! Make django_settings_is_configured return the first value always
1 parent 3779fc1 commit 9103942

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pytest_django/lazy_django.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest
99

1010

11-
_cache = {}
11+
_django_settings_is_configured = None
1212

1313

1414
def skip_if_no_django():
@@ -24,17 +24,17 @@ def django_settings_is_configured():
2424
configured flag in the Django settings object if django.conf has already
2525
been imported.
2626
"""
27-
try:
28-
return _cache["django_is_configured"]
29-
except KeyError:
27+
global _django_settings_is_configured
28+
29+
if _django_settings_is_configured is None:
3030
ret = bool(os.environ.get("DJANGO_SETTINGS_MODULE"))
3131

3232
if not ret and "django.conf" in sys.modules:
3333
ret = sys.modules["django.conf"].settings.configured
3434

35-
_cache["django_is_configured"] = ret
35+
_django_settings_is_configured = ret
3636

37-
return ret
37+
return _django_settings_is_configured
3838

3939

4040
def get_django_version():

0 commit comments

Comments
 (0)