diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-09-11 13:04:32 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-09-11 13:04:55 +0200 |
| commit | 97e8a2afb127fad8c71d084954a6bc38661375dd (patch) | |
| tree | 895dfc852f076518a3c72b4e56c73543415074eb /tests | |
| parent | 39cb3b08bc730e5ff8a10c2f2db1ac7458c4213f (diff) | |
[4.2.x] Fixed #34821 -- Prevented DEFAULT_FILE_STORAGE/STATICFILES_STORAGE settings from mutating the main STORAGES.
Regression in 6b965c600054f970bdf94017ecf2e0e6e0a4326b.
Backport of a7c73b944f51d6c92ec876fd7e0a171e7c01657d from main
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/deprecation/test_storages.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/deprecation/test_storages.py b/tests/deprecation/test_storages.py index 0574f3e880..99a1fc1884 100644 --- a/tests/deprecation/test_storages.py +++ b/tests/deprecation/test_storages.py @@ -32,6 +32,7 @@ class StaticfilesStorageDeprecationTests(TestCase): pass def test_settings_init(self): + old_staticfiles_storage = settings.STORAGES.get(STATICFILES_STORAGE_ALIAS) settings_module = ModuleType("fake_settings_module") settings_module.USE_TZ = True settings_module.STATICFILES_STORAGE = ( @@ -49,6 +50,11 @@ class StaticfilesStorageDeprecationTests(TestCase): ), }, ) + # settings.STORAGES is not mutated. + self.assertEqual( + settings.STORAGES.get(STATICFILES_STORAGE_ALIAS), + old_staticfiles_storage, + ) finally: del sys.modules["fake_settings_module"] @@ -161,6 +167,7 @@ class DefaultStorageDeprecationTests(TestCase): pass def test_settings_init(self): + old_default_storage = settings.STORAGES.get(DEFAULT_STORAGE_ALIAS) settings_module = ModuleType("fake_settings_module") settings_module.USE_TZ = True settings_module.DEFAULT_FILE_STORAGE = "django.core.files.storage.Storage" @@ -172,6 +179,11 @@ class DefaultStorageDeprecationTests(TestCase): fake_settings.STORAGES[DEFAULT_STORAGE_ALIAS], {"BACKEND": "django.core.files.storage.Storage"}, ) + # settings.STORAGES is not mutated. + self.assertEqual( + settings.STORAGES.get(DEFAULT_STORAGE_ALIAS), + old_default_storage, + ) finally: del sys.modules["fake_settings_module"] |
