-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Description
In pytest-dev/pytest-django#668 we just learned that Django raises ImproperlyConfigured
already when isinstance
is called on settings
.
I wonder if pytest's isclass
should be hardened in this regard to return False.
But the real fix would probably be for Django to exclude __class__
in the wrapped __getattr__
(or whatever triggers this).
What do you think?
In [10]: from django.conf import settings as django_settings
In [11]: isinstance(django_settings, type)
---------------------------------------------------------------------------
ImproperlyConfigured Traceback (most recent call last)
<ipython-input-11-9824ac31307c> in <module>()
----> 1 isinstance(django_settings, type)
/usr/lib/python3.7/site-packages/django/utils/functional.py in inner(self, *args)
211 def inner(self, *args):
212 if self._wrapped is empty:
--> 213 self._setup()
214 return func(self._wrapped, *args)
215 return inner
/usr/lib/python3.7/site-packages/django/conf/__init__.py in _setup(self, name)
40 "You must either define the environment variable %s "
41 "or call settings.configure() before accessing settings."
---> 42 % (desc, ENVIRONMENT_VARIABLE))
43
44 self._wrapped = Settings(settings_module)
ImproperlyConfigured: Requested settings, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Metadata
Metadata
Assignees
Labels
No labels