Opened 9 hours ago

Last modified 9 hours ago

#36635 new Uncategorized

Settings._explicit_settings attribute not accessible when using override_settings — at Version 1

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 (1)

comment:1 by mmdev, 9 hours ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top