summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2023-03-12 12:28:00 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-03-12 16:54:20 +0100
commit03bc92af978f2148c1141673c730f17772cd7037 (patch)
treeb07350231d8d9193c7f9790dc6f55ecc56cfb768 /tests/staticfiles_tests
parent4db33e96d1b5b4ba1a739e15b28835495f78eee4 (diff)
downloaddjango-03bc92af978f2148c1141673c730f17772cd7037.tar.gz
Fixed #34407 -- Reported filename when decoding fails in collectstatic's post_process.
Diffstat (limited to 'tests/staticfiles_tests')
-rw-r--r--tests/staticfiles_tests/project/nonutf8/nonutf8.css2
-rw-r--r--tests/staticfiles_tests/test_storage.py12
2 files changed, 14 insertions, 0 deletions
diff --git a/tests/staticfiles_tests/project/nonutf8/nonutf8.css b/tests/staticfiles_tests/project/nonutf8/nonutf8.css
new file mode 100644
index 0000000000..4d5e729088
--- /dev/null
+++ b/tests/staticfiles_tests/project/nonutf8/nonutf8.css
@@ -0,0 +1,2 @@
+/* éviter écrasement */
+.test { margin: 1 rem; }
diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py
index 06df05e196..759582122d 100644
--- a/tests/staticfiles_tests/test_storage.py
+++ b/tests/staticfiles_tests/test_storage.py
@@ -368,6 +368,18 @@ class TestHashedFiles:
self.assertEqual("Post-processing 'faulty.css' failed!\n\n", err.getvalue())
self.assertPostCondition()
+ @override_settings(
+ STATICFILES_DIRS=[os.path.join(TEST_ROOT, "project", "nonutf8")],
+ STATICFILES_FINDERS=["django.contrib.staticfiles.finders.FileSystemFinder"],
+ )
+ def test_post_processing_nonutf8(self):
+ finders.get_finder.cache_clear()
+ err = StringIO()
+ with self.assertRaises(UnicodeDecodeError):
+ call_command("collectstatic", interactive=False, verbosity=0, stderr=err)
+ self.assertEqual("Post-processing 'nonutf8.css' failed!\n\n", err.getvalue())
+ self.assertPostCondition()
+
@override_settings(
STORAGES={