summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJarosław Wygoda <jaroslaw@wygoda.me>2022-09-11 17:33:47 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-12 09:58:36 +0100
commit32940d390a00a30a6409282d314d617667892841 (patch)
tree3912c57c1b553833a8a798d92a33147fb87b3f0b /tests
parent1ec3f0961fedbe01f174b78ef2805a9d4f3844b1 (diff)
Refs #26029 -- Deprecated DEFAULT_FILE_STORAGE and STATICFILES_STORAGE settings.
Diffstat (limited to 'tests')
-rw-r--r--tests/deprecation/test_storages.py165
-rw-r--r--tests/file_storage/tests.py31
-rw-r--r--tests/file_uploads/tests.py7
-rw-r--r--tests/staticfiles_tests/test_forms.py9
-rw-r--r--tests/staticfiles_tests/test_management.py70
-rw-r--r--tests/staticfiles_tests/test_storage.py50
-rw-r--r--tests/staticfiles_tests/test_templatetags.py7
-rw-r--r--tests/test_utils/tests.py8
8 files changed, 313 insertions, 34 deletions
diff --git a/tests/deprecation/test_storages.py b/tests/deprecation/test_storages.py
new file mode 100644
index 0000000000..71ed3acdb0
--- /dev/null
+++ b/tests/deprecation/test_storages.py
@@ -0,0 +1,165 @@
+import sys
+from types import ModuleType
+
+from django.conf import (
+ DEFAULT_FILE_STORAGE_DEPRECATED_MSG,
+ DEFAULT_STORAGE_ALIAS,
+ STATICFILES_STORAGE_ALIAS,
+ STATICFILES_STORAGE_DEPRECATED_MSG,
+ Settings,
+ settings,
+)
+from django.contrib.staticfiles.storage import (
+ ManifestStaticFilesStorage,
+ staticfiles_storage,
+)
+from django.core.exceptions import ImproperlyConfigured
+from django.core.files.storage import Storage, StorageHandler, default_storage, storages
+from django.test import TestCase, ignore_warnings
+from django.utils.deprecation import RemovedInDjango51Warning
+
+
+class StaticfilesStorageDeprecationTests(TestCase):
+ msg = STATICFILES_STORAGE_DEPRECATED_MSG
+
+ def test_override_settings_warning(self):
+ with self.assertRaisesMessage(RemovedInDjango51Warning, self.msg):
+ with self.settings(
+ STATICFILES_STORAGE=(
+ "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
+ )
+ ):
+ pass
+
+ def test_settings_init(self):
+ settings_module = ModuleType("fake_settings_module")
+ settings_module.USE_TZ = True
+ settings_module.STATICFILES_STORAGE = (
+ "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
+ )
+ sys.modules["fake_settings_module"] = settings_module
+ try:
+ with self.assertRaisesMessage(RemovedInDjango51Warning, self.msg):
+ Settings("fake_settings_module")
+ finally:
+ del sys.modules["fake_settings_module"]
+
+ def test_access_warning(self):
+ with self.assertRaisesMessage(RemovedInDjango51Warning, self.msg):
+ settings.STATICFILES_STORAGE
+ # Works a second time.
+ with self.assertRaisesMessage(RemovedInDjango51Warning, self.msg):
+ settings.STATICFILES_STORAGE
+
+ @ignore_warnings(category=RemovedInDjango51Warning)
+ def test_access(self):
+ with self.settings(
+ STATICFILES_STORAGE=(
+ "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
+ )
+ ):
+ self.assertEqual(
+ settings.STATICFILES_STORAGE,
+ "django.contrib.staticfiles.storage.ManifestStaticFilesStorage",
+ )
+ # Works a second time.
+ self.assertEqual(
+ settings.STATICFILES_STORAGE,
+ "django.contrib.staticfiles.storage.ManifestStaticFilesStorage",
+ )
+
+ def test_use_both_error(self):
+ msg = "STATICFILES_STORAGE/STORAGES are mutually exclusive."
+ settings_module = ModuleType("fake_settings_module")
+ settings_module.USE_TZ = True
+ settings_module.STATICFILES_STORAGE = (
+ "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
+ )
+ settings_module.STORAGES = {}
+ sys.modules["fake_settings_module"] = settings_module
+ try:
+ with self.assertRaisesMessage(ImproperlyConfigured, msg):
+ Settings("fake_settings_module")
+ finally:
+ del sys.modules["fake_settings_module"]
+
+ @ignore_warnings(category=RemovedInDjango51Warning)
+ def test_storage(self):
+ empty_storages = StorageHandler()
+ with self.settings(
+ STATICFILES_STORAGE=(
+ "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
+ )
+ ):
+ self.assertIsInstance(
+ storages[STATICFILES_STORAGE_ALIAS],
+ ManifestStaticFilesStorage,
+ )
+ self.assertIsInstance(
+ empty_storages[STATICFILES_STORAGE_ALIAS],
+ ManifestStaticFilesStorage,
+ )
+ self.assertIsInstance(staticfiles_storage, ManifestStaticFilesStorage)
+
+
+class DefaultStorageDeprecationTests(TestCase):
+ msg = DEFAULT_FILE_STORAGE_DEPRECATED_MSG
+
+ def test_override_settings_warning(self):
+ with self.assertRaisesMessage(RemovedInDjango51Warning, self.msg):
+ with self.settings(
+ DEFAULT_FILE_STORAGE=("django.core.files.storage.Storage")
+ ):
+ pass
+
+ def test_settings_init(self):
+ settings_module = ModuleType("fake_settings_module")
+ settings_module.USE_TZ = True
+ settings_module.DEFAULT_FILE_STORAGE = "django.core.files.storage.Storage"
+ sys.modules["fake_settings_module"] = settings_module
+ try:
+ with self.assertRaisesMessage(RemovedInDjango51Warning, self.msg):
+ Settings("fake_settings_module")
+ finally:
+ del sys.modules["fake_settings_module"]
+
+ def test_access_warning(self):
+ with self.assertRaisesMessage(RemovedInDjango51Warning, self.msg):
+ settings.DEFAULT_FILE_STORAGE
+ # Works a second time.
+ with self.assertRaisesMessage(RemovedInDjango51Warning, self.msg):
+ settings.DEFAULT_FILE_STORAGE
+
+ @ignore_warnings(category=RemovedInDjango51Warning)
+ def test_access(self):
+ with self.settings(DEFAULT_FILE_STORAGE="django.core.files.storage.Storage"):
+ self.assertEqual(
+ settings.DEFAULT_FILE_STORAGE,
+ "django.core.files.storage.Storage",
+ )
+ # Works a second time.
+ self.assertEqual(
+ settings.DEFAULT_FILE_STORAGE,
+ "django.core.files.storage.Storage",
+ )
+
+ def test_use_both_error(self):
+ msg = "DEFAULT_FILE_STORAGE/STORAGES are mutually exclusive."
+ settings_module = ModuleType("fake_settings_module")
+ settings_module.USE_TZ = True
+ settings_module.DEFAULT_FILE_STORAGE = "django.core.files.storage.Storage"
+ settings_module.STORAGES = {}
+ sys.modules["fake_settings_module"] = settings_module
+ try:
+ with self.assertRaisesMessage(ImproperlyConfigured, msg):
+ Settings("fake_settings_module")
+ finally:
+ del sys.modules["fake_settings_module"]
+
+ @ignore_warnings(category=RemovedInDjango51Warning)
+ def test_storage(self):
+ empty_storages = StorageHandler()
+ with self.settings(DEFAULT_FILE_STORAGE="django.core.files.storage.Storage"):
+ self.assertIsInstance(storages[DEFAULT_STORAGE_ALIAS], Storage)
+ self.assertIsInstance(empty_storages[DEFAULT_STORAGE_ALIAS], Storage)
+ self.assertIsInstance(default_storage, Storage)
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py
index d4e5969519..4616aad10a 100644
--- a/tests/file_storage/tests.py
+++ b/tests/file_storage/tests.py
@@ -11,10 +11,15 @@ from io import StringIO
from pathlib import Path
from urllib.request import urlopen
+from django.conf import DEFAULT_STORAGE_ALIAS, STATICFILES_STORAGE_ALIAS
from django.core.cache import cache
from django.core.exceptions import SuspiciousFileOperation
from django.core.files.base import ContentFile, File
-from django.core.files.storage import FileSystemStorage, InvalidStorageError
+from django.core.files.storage import (
+ GET_STORAGE_CLASS_DEPRECATED_MSG,
+ FileSystemStorage,
+ InvalidStorageError,
+)
from django.core.files.storage import Storage as BaseStorage
from django.core.files.storage import (
StorageHandler,
@@ -30,10 +35,11 @@ from django.core.files.uploadedfile import (
from django.db.models import FileField
from django.db.models.fields.files import FileDescriptor
from django.test import LiveServerTestCase, SimpleTestCase, TestCase, override_settings
-from django.test.utils import requires_tz_support
+from django.test.utils import ignore_warnings, requires_tz_support
from django.urls import NoReverseMatch, reverse_lazy
from django.utils import timezone
from django.utils._os import symlinks_supported
+from django.utils.deprecation import RemovedInDjango51Warning
from .models import Storage, callable_storage, temp_storage, temp_storage_location
@@ -41,6 +47,7 @@ FILE_SUFFIX_REGEX = "[A-Za-z0-9]{7}"
class GetStorageClassTests(SimpleTestCase):
+ @ignore_warnings(category=RemovedInDjango51Warning)
def test_get_filesystem_storage(self):
"""
get_storage_class returns the class for a storage backend name/path.
@@ -50,6 +57,7 @@ class GetStorageClassTests(SimpleTestCase):
FileSystemStorage,
)
+ @ignore_warnings(category=RemovedInDjango51Warning)
def test_get_invalid_storage_module(self):
"""
get_storage_class raises an error if the requested import don't exist.
@@ -57,6 +65,7 @@ class GetStorageClassTests(SimpleTestCase):
with self.assertRaisesMessage(ImportError, "No module named 'storage'"):
get_storage_class("storage.NonexistentStorage")
+ @ignore_warnings(category=RemovedInDjango51Warning)
def test_get_nonexistent_storage_class(self):
"""
get_storage_class raises an error if the requested class don't exist.
@@ -64,6 +73,7 @@ class GetStorageClassTests(SimpleTestCase):
with self.assertRaises(ImportError):
get_storage_class("django.core.files.storage.NonexistentStorage")
+ @ignore_warnings(category=RemovedInDjango51Warning)
def test_get_nonexistent_storage_module(self):
"""
get_storage_class raises an error if the requested module don't exist.
@@ -75,6 +85,11 @@ class GetStorageClassTests(SimpleTestCase):
"django.core.files.nonexistent_storage.NonexistentStorage"
)
+ def test_deprecation_warning(self):
+ msg = GET_STORAGE_CLASS_DEPRECATED_MSG
+ with self.assertRaisesMessage(RemovedInDjango51Warning, msg):
+ get_storage_class("django.core.files.storage.FileSystemStorage"),
+
class FileSystemStorageTests(unittest.TestCase):
def test_deconstruction(self):
@@ -1179,7 +1194,17 @@ class StorageHandlerTests(SimpleTestCase):
def test_defaults(self):
storages = StorageHandler()
- self.assertEqual(storages.backends, {})
+ self.assertEqual(
+ storages.backends,
+ {
+ DEFAULT_STORAGE_ALIAS: {
+ "BACKEND": "django.core.files.storage.FileSystemStorage",
+ },
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
+ },
+ },
+ )
def test_nonexistent_alias(self):
msg = "Could not find config for 'nonexistent' in settings.STORAGES."
diff --git a/tests/file_uploads/tests.py b/tests/file_uploads/tests.py
index f3d926ac5f..693efc4c62 100644
--- a/tests/file_uploads/tests.py
+++ b/tests/file_uploads/tests.py
@@ -9,6 +9,7 @@ from io import BytesIO, StringIO
from unittest import mock
from urllib.parse import quote
+from django.conf import DEFAULT_STORAGE_ALIAS
from django.core.exceptions import SuspiciousFileOperation
from django.core.files import temp as tempfile
from django.core.files.storage import default_storage
@@ -806,7 +807,11 @@ class DirectoryCreationTests(SimpleTestCase):
sys.platform == "win32", "Python on Windows doesn't have working os.chmod()."
)
@override_settings(
- DEFAULT_FILE_STORAGE="django.core.files.storage.FileSystemStorage"
+ STORAGES={
+ DEFAULT_STORAGE_ALIAS: {
+ "BACKEND": "django.core.files.storage.FileSystemStorage",
+ }
+ }
)
def test_readonly_root(self):
"""Permission errors are not swallowed"""
diff --git a/tests/staticfiles_tests/test_forms.py b/tests/staticfiles_tests/test_forms.py
index ad662d7321..489140a62c 100644
--- a/tests/staticfiles_tests/test_forms.py
+++ b/tests/staticfiles_tests/test_forms.py
@@ -1,5 +1,6 @@
from urllib.parse import urljoin
+from django.conf import STATICFILES_STORAGE_ALIAS
from django.contrib.staticfiles import storage
from django.forms import Media
from django.templatetags.static import static
@@ -12,9 +13,13 @@ class StaticTestStorage(storage.StaticFilesStorage):
@override_settings(
- STATIC_URL="http://media.example.com/static/",
INSTALLED_APPS=("django.contrib.staticfiles",),
- STATICFILES_STORAGE="staticfiles_tests.test_forms.StaticTestStorage",
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "staticfiles_tests.test_forms.StaticTestStorage",
+ "OPTIONS": {"location": "http://media.example.com/static/"},
+ }
+ },
)
class StaticFilesFormsMediaTestCase(SimpleTestCase):
def test_absolute_url(self):
diff --git a/tests/staticfiles_tests/test_management.py b/tests/staticfiles_tests/test_management.py
index 6dec3a67bd..8398195cec 100644
--- a/tests/staticfiles_tests/test_management.py
+++ b/tests/staticfiles_tests/test_management.py
@@ -9,7 +9,7 @@ from unittest import mock
from admin_scripts.tests import AdminScriptTestCase
-from django.conf import settings
+from django.conf import STATICFILES_STORAGE_ALIAS, settings
from django.contrib.staticfiles import storage
from django.contrib.staticfiles.management.commands import collectstatic, runserver
from django.core.exceptions import ImproperlyConfigured
@@ -141,16 +141,24 @@ class TestConfiguration(StaticFilesTestCase):
try:
storage.staticfiles_storage._wrapped = empty
with self.settings(
- STATICFILES_STORAGE=(
- "django.contrib.staticfiles.storage.StaticFilesStorage"
- )
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": (
+ "django.contrib.staticfiles.storage.StaticFilesStorage"
+ )
+ }
+ }
):
command = collectstatic.Command()
self.assertTrue(command.is_local_storage())
storage.staticfiles_storage._wrapped = empty
with self.settings(
- STATICFILES_STORAGE="staticfiles_tests.storage.DummyStorage"
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "staticfiles_tests.storage.DummyStorage"
+ }
+ }
):
command = collectstatic.Command()
self.assertFalse(command.is_local_storage())
@@ -241,9 +249,13 @@ class TestCollectionVerbosity(CollectionTestCase):
self.assertIn(self.copying_msg, output)
@override_settings(
- STATICFILES_STORAGE=(
- "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
- )
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": (
+ "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
+ )
+ },
+ }
)
def test_verbosity_1_with_post_process(self):
stdout = StringIO()
@@ -251,9 +263,13 @@ class TestCollectionVerbosity(CollectionTestCase):
self.assertNotIn(self.post_process_msg, stdout.getvalue())
@override_settings(
- STATICFILES_STORAGE=(
- "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
- )
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": (
+ "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
+ )
+ },
+ }
)
def test_verbosity_2_with_post_process(self):
stdout = StringIO()
@@ -280,7 +296,11 @@ class TestCollectionClear(CollectionTestCase):
super().run_collectstatic(clear=True)
@override_settings(
- STATICFILES_STORAGE="staticfiles_tests.storage.PathNotImplementedStorage"
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "staticfiles_tests.storage.PathNotImplementedStorage"
+ },
+ }
)
def test_handle_path_notimplemented(self):
self.run_collectstatic()
@@ -395,7 +415,11 @@ class TestCollectionDryRun(TestNoFilesCreated, CollectionTestCase):
@override_settings(
- STATICFILES_STORAGE="django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
+ },
+ }
)
class TestCollectionDryRunManifestStaticFilesStorage(TestCollectionDryRun):
pass
@@ -518,7 +542,13 @@ class TestCollectionOverwriteWarning(CollectionTestCase):
self.assertNotIn(self.warning_string, output)
-@override_settings(STATICFILES_STORAGE="staticfiles_tests.storage.DummyStorage")
+@override_settings(
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "staticfiles_tests.storage.DummyStorage"
+ },
+ }
+)
class TestCollectionNonLocalStorage(TestNoFilesCreated, CollectionTestCase):
"""
Tests for a Storage that implements get_modified_time() but not path()
@@ -540,7 +570,11 @@ class TestCollectionNonLocalStorage(TestNoFilesCreated, CollectionTestCase):
class TestCollectionNeverCopyStorage(CollectionTestCase):
@override_settings(
- STATICFILES_STORAGE="staticfiles_tests.storage.NeverCopyRemoteStorage"
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "staticfiles_tests.storage.NeverCopyRemoteStorage"
+ },
+ }
)
def test_skips_newer_files_in_remote_storage(self):
"""
@@ -607,7 +641,11 @@ class TestCollectionLinks(TestDefaults, CollectionTestCase):
self.assertFalse(os.path.lexists(broken_symlink_path))
@override_settings(
- STATICFILES_STORAGE="staticfiles_tests.storage.PathNotImplementedStorage"
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "staticfiles_tests.storage.PathNotImplementedStorage"
+ }
+ }
)
def test_no_remote_link(self):
with self.assertRaisesMessage(
diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py
index f2f1899aac..11b160945e 100644
--- a/tests/staticfiles_tests/test_storage.py
+++ b/tests/staticfiles_tests/test_storage.py
@@ -8,7 +8,7 @@ from io import StringIO
from pathlib import Path
from unittest import mock
-from django.conf import settings
+from django.conf import STATICFILES_STORAGE_ALIAS, settings
from django.contrib.staticfiles import finders, storage
from django.contrib.staticfiles.management.commands.collectstatic import (
Command as CollectstaticCommand,
@@ -369,7 +369,13 @@ class TestHashedFiles:
self.assertPostCondition()
-@override_settings(STATICFILES_STORAGE="staticfiles_tests.storage.ExtraPatternsStorage")
+@override_settings(
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "staticfiles_tests.storage.ExtraPatternsStorage",
+ },
+ }
+)
class TestExtraPatternsStorage(CollectionTestCase):
def setUp(self):
storage.staticfiles_storage.hashed_files.clear() # avoid cache interference
@@ -399,7 +405,11 @@ class TestExtraPatternsStorage(CollectionTestCase):
@override_settings(
- STATICFILES_STORAGE="django.contrib.staticfiles.storage.ManifestStaticFilesStorage",
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage",
+ },
+ }
)
class TestCollectionManifestStorage(TestHashedFiles, CollectionTestCase):
"""
@@ -559,7 +569,13 @@ class TestCollectionManifestStorage(TestHashedFiles, CollectionTestCase):
self.assertEqual(manifest_content, {"dummy.txt": "dummy.txt"})
-@override_settings(STATICFILES_STORAGE="staticfiles_tests.storage.NoneHashStorage")
+@override_settings(
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "staticfiles_tests.storage.NoneHashStorage",
+ },
+ }
+)
class TestCollectionNoneHashStorage(CollectionTestCase):
hashed_file_path = hashed_file_path
@@ -569,7 +585,11 @@ class TestCollectionNoneHashStorage(CollectionTestCase):
@override_settings(
- STATICFILES_STORAGE="staticfiles_tests.storage.NoPostProcessReplacedPathStorage"
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "staticfiles_tests.storage.NoPostProcessReplacedPathStorage",
+ },
+ }
)
class TestCollectionNoPostProcessReplacedPaths(CollectionTestCase):
run_collectstatic_in_setUp = False
@@ -580,7 +600,13 @@ class TestCollectionNoPostProcessReplacedPaths(CollectionTestCase):
self.assertIn("post-processed", stdout.getvalue())
-@override_settings(STATICFILES_STORAGE="staticfiles_tests.storage.SimpleStorage")
+@override_settings(
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "staticfiles_tests.storage.SimpleStorage",
+ },
+ }
+)
class TestCollectionSimpleStorage(CollectionTestCase):
hashed_file_path = hashed_file_path
@@ -733,7 +759,11 @@ class TestStaticFilePermissions(CollectionTestCase):
@override_settings(
FILE_UPLOAD_PERMISSIONS=0o655,
FILE_UPLOAD_DIRECTORY_PERMISSIONS=0o765,
- STATICFILES_STORAGE="staticfiles_tests.test_storage.CustomStaticFilesStorage",
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "staticfiles_tests.test_storage.CustomStaticFilesStorage",
+ },
+ },
)
def test_collect_static_files_subclass_of_static_storage(self):
call_command("collectstatic", **self.command_params)
@@ -753,7 +783,11 @@ class TestStaticFilePermissions(CollectionTestCase):
@override_settings(
- STATICFILES_STORAGE="django.contrib.staticfiles.storage.ManifestStaticFilesStorage",
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage",
+ },
+ }
)
class TestCollectionHashedFilesCache(CollectionTestCase):
"""
diff --git a/tests/staticfiles_tests/test_templatetags.py b/tests/staticfiles_tests/test_templatetags.py
index 4cc3f95ab1..9b8bcf1938 100644
--- a/tests/staticfiles_tests/test_templatetags.py
+++ b/tests/staticfiles_tests/test_templatetags.py
@@ -1,3 +1,4 @@
+from django.conf import STATICFILES_STORAGE_ALIAS
from django.test import override_settings
from .cases import StaticFilesTestCase
@@ -12,7 +13,11 @@ class TestTemplateTag(StaticFilesTestCase):
)
@override_settings(
- STATICFILES_STORAGE="staticfiles_tests.storage.QueryStringStorage"
+ STORAGES={
+ STATICFILES_STORAGE_ALIAS: {
+ "BACKEND": "staticfiles_tests.storage.QueryStringStorage"
+ },
+ }
)
def test_template_tag_escapes(self):
"""
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
index 79757045dd..a377479d38 100644
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -5,7 +5,7 @@ import warnings
from io import StringIO
from unittest import mock
-from django.conf import settings
+from django.conf import STATICFILES_STORAGE_ALIAS, settings
from django.contrib.staticfiles.finders import get_finder, get_finders
from django.contrib.staticfiles.storage import staticfiles_storage
from django.core.exceptions import ImproperlyConfigured
@@ -2106,12 +2106,14 @@ class OverrideSettingsTests(SimpleTestCase):
def test_override_staticfiles_storage(self):
"""
- Overriding the STATICFILES_STORAGE setting should be reflected in
+ Overriding the STORAGES setting should be reflected in
the value of django.contrib.staticfiles.storage.staticfiles_storage.
"""
new_class = "ManifestStaticFilesStorage"
new_storage = "django.contrib.staticfiles.storage." + new_class
- with self.settings(STATICFILES_STORAGE=new_storage):
+ with self.settings(
+ STORAGES={STATICFILES_STORAGE_ALIAS: {"BACKEND": new_storage}}
+ ):
self.assertEqual(staticfiles_storage.__class__.__name__, new_class)
def test_override_staticfiles_finders(self):