Re: [Django] #30871: override_settings() does not restore partially deleted settings. (was: override_settings() does not restore partially deleted settings)

2019-10-11 Thread Django
#30871: override_settings() does not restore partially deleted settings.
---+--
 Reporter:  Hodossy, Szabolcs  |Owner:  nobody
 Type:  Bug|   Status:  closed
Component:  Testing framework  |  Version:  master
 Severity:  Normal |   Resolution:  invalid
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by felixxm):

 * status:  new => closed
 * version:  2.2 => master
 * resolution:   => invalid


Comment:

 Thanks for this report, however it is not a valid usage of the
 `override_settings()` decorator (see
 
[https://docs.djangoproject.com/en/dev/topics/testing/tools/#django.test.override_settings
 documentation]). You can simulate the absence of a setting, but you cannot
 modify it partially with `override_settings()`. You should rather create a
 local copy and override the setting e.g.
 {{{

 def test_access_callback_azure(self):
 ...
 auth_adfs_setting = settings.AUTH_ADFS.copy()
 del auth_adfs_setting["SERVER"]
 with self.settings(AUTH_ADFS=auth_adfs_setting):
  ...
 }}}

 Closing per TicketClosingReasons/UseSupportChannels.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.03757b07668a420aa03e6a8b412c7f9c%40djangoproject.com.


[Django] #30871: override_settings() does not restore partially deleted settings

2019-10-11 Thread Django
#30871: override_settings() does not restore partially deleted settings
-+
   Reporter:  Hodossy, Szabolcs  |  Owner:  nobody
   Type:  Bug| Status:  new
  Component:  Testing framework  |Version:  2.2
   Severity:  Normal |   Keywords:
   Triage Stage:  Unreviewed |  Has patch:  0
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+
 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.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.af8574187606207be931198233504f0a%40djangoproject.com.