Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d46d272

Browse files
committedJan 20, 2025··
Use updated settings for static files storage
1 parent 4e0bb18 commit d46d272

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed
 

‎tests/tests.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from django.core.cache import caches
88
from django.core.management import call_command
99
from django.template.loader import render_to_string
10-
from django.test import override_settings
1110

1211
import sri
1312
from sri.algorithm import DEFAULT_ALGORITHM
@@ -140,17 +139,16 @@ def test_uses_default_cache():
140139
assert sri.utils.get_cache() == caches["default"]
141140

142141

143-
@override_settings(
144-
CACHES={"sri": {"BACKEND": "django.core.cache.backends.dummy.DummyCache"}}
145-
)
146-
def test_uses_dedicated_cache():
142+
def test_uses_dedicated_cache(settings):
143+
settings.CACHES = {
144+
"sri": {"BACKEND": "django.core.cache.backends.dummy.DummyCache"}
145+
}
147146
assert sri.utils.get_cache() == caches["sri"]
148147

149148

150149
@pytest.mark.parametrize("algorithm", sri.Algorithm)
151150
@pytest.mark.parametrize("file", TEST_FILES)
152151
def test_caches_hash(algorithm, file):
153-
154152
file_path = sri.utils.get_static_path(file)
155153
cache_key = sri.hashers.get_cache_key(file_path, algorithm)
156154
cache = sri.utils.get_cache()
@@ -160,11 +158,13 @@ def test_caches_hash(algorithm, file):
160158
assert cache.get(cache_key) == digest
161159

162160

163-
@override_settings(
164-
STATICFILES_STORAGE="django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
165-
)
166161
@pytest.mark.parametrize("file", TEST_FILES)
167-
def test_manifest_storage(file):
162+
def test_manifest_storage(settings, file):
163+
settings.STORAGES = {
164+
"staticfiles": {
165+
"BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
166+
}
167+
}
168168
call_command("collectstatic", interactive=False, clear=True, verbosity=0)
169169

170170
file_path = sri.utils.get_static_path(file)
@@ -177,9 +177,6 @@ def test_manifest_storage(file):
177177
assert str(file_path).endswith(staticfiles_storage.stored_name(file))
178178

179179

180-
@override_settings(
181-
STATICFILES_STORAGE="django.contrib.staticfiles.storage.StaticFilesStorage"
182-
)
183180
@pytest.mark.parametrize("file", TEST_FILES)
184181
def test_default_storage(file):
185182
# Test for issue #70

0 commit comments

Comments
 (0)
Please sign in to comment.