diff options
| author | Tim Graham <timograham@gmail.com> | 2018-10-27 10:30:28 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-10-27 11:58:29 -0400 |
| commit | f892781b957f674806a227a10c58768f66a48c07 (patch) | |
| tree | 050922b97e1c8c4f1509a1811ed5c412e433252f /tests/staticfiles_tests/test_storage.py | |
| parent | 55b0b766fbeb2f71e68331a2e14205702f681012 (diff) | |
Fixed #28606 -- Deprecated CachedStaticFilesStorage.
Diffstat (limited to 'tests/staticfiles_tests/test_storage.py')
| -rw-r--r-- | tests/staticfiles_tests/test_storage.py | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py index f7a22b7427..97e3b9113d 100644 --- a/tests/staticfiles_tests/test_storage.py +++ b/tests/staticfiles_tests/test_storage.py @@ -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): """ |
