mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #28606 -- Deprecated CachedStaticFilesStorage.
This commit is contained in:
@@ -12,7 +12,8 @@ from django.contrib.staticfiles.management.commands.collectstatic import (
|
||||
)
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
from django.core.management import call_command
|
||||
from django.test import override_settings
|
||||
from django.test import SimpleTestCase, ignore_warnings, override_settings
|
||||
from django.utils.deprecation import RemovedInDjango31Warning
|
||||
|
||||
from .cases import CollectionTestCase
|
||||
from .settings import TEST_ROOT
|
||||
@@ -43,9 +44,6 @@ class TestHashedFiles:
|
||||
pass
|
||||
|
||||
def test_template_tag_return(self):
|
||||
"""
|
||||
Test the CachedStaticFilesStorage backend.
|
||||
"""
|
||||
self.assertStaticRaises(ValueError, "does/not/exist.png", "/static/does/not/exist.png")
|
||||
self.assertStaticRenders("test/file.txt", "/static/test/file.dad0999e4f8f.txt")
|
||||
self.assertStaticRenders("test/file.txt", "/static/test/file.dad0999e4f8f.txt", asvar=True)
|
||||
@@ -232,6 +230,7 @@ class TestHashedFiles:
|
||||
self.assertPostCondition()
|
||||
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango31Warning)
|
||||
@override_settings(
|
||||
STATICFILES_STORAGE='django.contrib.staticfiles.storage.CachedStaticFilesStorage',
|
||||
)
|
||||
@@ -299,10 +298,20 @@ class TestCollectionCachedStorage(TestHashedFiles, CollectionTestCase):
|
||||
self.hashed_file_path('cached/styles.css')
|
||||
|
||||
|
||||
@override_settings(
|
||||
STATICFILES_STORAGE='staticfiles_tests.storage.ExtraPatternsCachedStaticFilesStorage',
|
||||
)
|
||||
class TestExtraPatternsCachedStorage(CollectionTestCase):
|
||||
class TestCachedStaticFilesStorageDeprecation(SimpleTestCase):
|
||||
def test_warning(self):
|
||||
from django.contrib.staticfiles.storage import CachedStaticFilesStorage
|
||||
from django.utils.deprecation import RemovedInDjango31Warning
|
||||
msg = (
|
||||
'CachedStaticFilesStorage is deprecated in favor of '
|
||||
'ManifestStaticFilesStorage.'
|
||||
)
|
||||
with self.assertRaisesMessage(RemovedInDjango31Warning, msg):
|
||||
CachedStaticFilesStorage()
|
||||
|
||||
|
||||
@override_settings(STATICFILES_STORAGE='staticfiles_tests.storage.ExtraPatternsStorage')
|
||||
class TestExtraPatternsStorage(CollectionTestCase):
|
||||
|
||||
def setUp(self):
|
||||
storage.staticfiles_storage.hashed_files.clear() # avoid cache interference
|
||||
@@ -437,13 +446,8 @@ class TestCollectionManifestStorage(TestHashedFiles, CollectionTestCase):
|
||||
self.hashed_file_path(missing_file_name)
|
||||
|
||||
|
||||
@override_settings(
|
||||
STATICFILES_STORAGE='staticfiles_tests.storage.SimpleCachedStaticFilesStorage',
|
||||
)
|
||||
class TestCollectionSimpleCachedStorage(CollectionTestCase):
|
||||
"""
|
||||
Tests for the Cache busting storage
|
||||
"""
|
||||
@override_settings(STATICFILES_STORAGE='staticfiles_tests.storage.SimpleStorage')
|
||||
class TestCollectionSimpleStorage(CollectionTestCase):
|
||||
hashed_file_path = hashed_file_path
|
||||
|
||||
def setUp(self):
|
||||
@@ -451,9 +455,6 @@ class TestCollectionSimpleCachedStorage(CollectionTestCase):
|
||||
super().setUp()
|
||||
|
||||
def test_template_tag_return(self):
|
||||
"""
|
||||
Test the CachedStaticFilesStorage backend.
|
||||
"""
|
||||
self.assertStaticRaises(ValueError, "does/not/exist.png", "/static/does/not/exist.png")
|
||||
self.assertStaticRenders("test/file.txt", "/static/test/file.deploy12345.txt")
|
||||
self.assertStaticRenders("cached/styles.css", "/static/cached/styles.deploy12345.css")
|
||||
@@ -543,7 +544,7 @@ class TestStaticFilePermissions(CollectionTestCase):
|
||||
|
||||
|
||||
@override_settings(
|
||||
STATICFILES_STORAGE='django.contrib.staticfiles.storage.CachedStaticFilesStorage',
|
||||
STATICFILES_STORAGE='django.contrib.staticfiles.storage.ManifestStaticFilesStorage',
|
||||
)
|
||||
class TestCollectionHashedFilesCache(CollectionTestCase):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user