Opened 8 weeks ago

Closed 8 weeks ago

#36635 closed Uncategorized (wontfix)

Settings._explicit_settings attribute not accessible when using override_settings

Reported by: mmdev Owned by:
Component: Testing framework Version: 5.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by mmdev)

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:

from django.test import override_settings
from django.conf import settings

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

As a context manager:

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.

Change History (2)

comment:1 by mmdev, 8 weeks ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 8 weeks ago

Resolution: wontfix
Status: newclosed

_explicit_settings is an undocumented, internal, implementation detail. You should not rely on it.

Note: See TracTickets for help on using tickets.
Back to Top