Opened 5 years ago
Closed 5 years ago
#30871 closed Bug (invalid)
override_settings() does not restore partially deleted settings.
Reported by: | Hodossy, Szabolcs | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When a settings is a dictionary, and only a key in that dicitonary needs to be deleted for a test, the @override_settings() decorator does not restore the original settings value.
It is a common practice for apps to use a single settings dictionary for their own configuration. A quick example can be seen here with the django-auth-adfs package: https://github.com/hodossy/django-auth-adfs at commit e11eca87ef96a3a074fc0846feb71183182e53dd.
To reproduce the issue, you can clone the project, install dependecies and run 'python manage.py test' to see test failing with KeyError due to above error.
Change History (1)
comment:1 by , 5 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Summary: | override_settings() does not restore partially deleted settings → override_settings() does not restore partially deleted settings. |
Version: | 2.2 → master |
Thanks for this report, however it is not a valid usage of the
override_settings()
decorator (see documentation). You can simulate the absence of a setting, but you cannot modify it partially withoverride_settings()
. You should rather create a local copy and override the setting e.g.Closing per TicketClosingReasons/UseSupportChannels.