#36635: Settings._explicit_settings attribute not accessible when using
override_settings
-----------------------+---------------------------------------------
     Reporter:  mmdev  |                     Type:  Uncategorized
       Status:  new    |                Component:  Testing framework
      Version:  5.2    |                 Severity:  Normal
     Keywords:         |             Triage Stage:  Unreviewed
    Has patch:  0      |      Needs documentation:  0
  Needs tests:  0      |  Patch needs improvement:  0
Easy pickings:  1      |                    UI/UX:  0
-----------------------+---------------------------------------------
 The `Settings._explicit_settings` attribute, which is always populated by
 `Settings.__init__()`, becomes inaccessible when the `override_settings`
 decorator or context manager is used. This causes an `AttributeError` when
 trying to access this attribute, creating inconsistent behavior.

 == Steps to Reproduce

 As a decorator:
 {{{#!python
 from django.test import override_settings

 @override_settings(KEY="VALUE")
 def test_override_settings(settings):
     assert settings._explicit_settings  # Raises AttributeError
 }}}

 As a context manager:
 {{{#!python
 from django.test import override_settings
 from django.conf import settings

 with override_settings(KEY="VALUE"):
     settings._explicit_settings  # Raises AttributeError
 }}}

 Both cases raise `AttributeError: '_explicit_settings'` but work correctly
 without `override_settings`.

 == Expected Behavior

 The behavior should be consistent: if `_explicit_settings` is accessible
 without `override_settings`, it should remain accessible when using
 `override_settings` (both as a decorator and context manager). This
 attribute is an internal part of the Settings API and may be needed by
 test code to inspect which settings were explicitly set in the settings
 module.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36635>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070199a2fd250d-0c184e96-c547-42de-bbf9-2adb78eaa2ab-000000%40eu-central-1.amazonses.com.

Reply via email to