diff options
| author | James Bligh <blighj@users.noreply.github.com> | 2026-03-04 14:12:06 +0000 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-03-04 16:15:48 -0500 |
| commit | 36be97b99d4de786746a8d80bbcd41de03752df9 (patch) | |
| tree | 1d2242acc6854e502ac84bf286c8d62477001350 /tests/staticfiles_tests/test_storage.py | |
| parent | 35dab0ad9ee2ed23101420cb0f253deda2818191 (diff) | |
Fixed #21080 -- Ignored urls inside comments during collectstatic.
Thanks Mariusz Felisiak for the review.
Co-authored-by: Nathan Gaberel <nathan@gnab.fr>
Diffstat (limited to 'tests/staticfiles_tests/test_storage.py')
| -rw-r--r-- | tests/staticfiles_tests/test_storage.py | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py index e09f9eda1c..cdb6fd3c7e 100644 --- a/tests/staticfiles_tests/test_storage.py +++ b/tests/staticfiles_tests/test_storage.py @@ -65,7 +65,7 @@ class TestHashedFiles: def test_path_ignored_completely(self): relpath = self.hashed_file_path("cached/css/ignored.css") - self.assertEqual(relpath, "cached/css/ignored.55e7c226dda1.css") + self.assertEqual(relpath, "cached/css/ignored.0e15ac4a4fb4.css") with storage.staticfiles_storage.open(relpath) as relfile: content = relfile.read() self.assertIn(b"#foobar", content) @@ -75,6 +75,22 @@ class TestHashedFiles: self.assertIn(b"chrome:foobar", content) self.assertIn(b"//foobar", content) self.assertIn(b"url()", content) + self.assertIn(b'/* @import url("non_exist.css") */', content) + self.assertIn(b'/* url("non_exist.png") */', content) + self.assertIn(b'@import url("non_exist.css")', content) + self.assertIn(b'url("non_exist.png")', content) + self.assertIn(b"@import url(other.css)", content) + self.assertIn( + b'background: #d3d6d8 /*url("does.not.exist.png")*/ ' + b'url("/static/cached/img/relative.acae32e4532b.png");', + content, + ) + self.assertIn( + b'background: #d3d6d8 /* url("does.not.exist.png") */ ' + b'url("/static/cached/img/relative.acae32e4532b.png") ' + b'/*url("does.not.exist.either.png")*/', + content, + ) self.assertPostCondition() def test_path_with_querystring(self): @@ -698,7 +714,7 @@ class TestCollectionJSModuleImportAggregationManifestStorage(CollectionTestCase) def test_module_import(self): relpath = self.hashed_file_path("cached/module.js") - self.assertEqual(relpath, "cached/module.4326210cf0bd.js") + self.assertEqual(relpath, "cached/module.eaa407b94311.js") tests = [ # Relative imports. b'import testConst from "./module_test.477bbebe77f0.js";', @@ -721,6 +737,15 @@ class TestCollectionJSModuleImportAggregationManifestStorage(CollectionTestCase) b" firstVar1 as firstVarAlias,\n" b" $second_var_2 as secondVarAlias\n" b'} from "./module_test.477bbebe77f0.js";', + # Ignore block comments + b'/* export * from "./module_test_missing.js"; */', + b"/*\n" + b'import rootConst from "/static/absolute_root_missing.js";\n' + b'const dynamicModule = import("./module_test_missing.js");\n' + b"*/", + # Ignore line comments + b'// import testConst from "./module_test_missing.js";', + b'// const dynamicModule = import("./module_test_missing.js");', ] with storage.staticfiles_storage.open(relpath) as relfile: content = relfile.read() @@ -730,7 +755,7 @@ class TestCollectionJSModuleImportAggregationManifestStorage(CollectionTestCase) def test_aggregating_modules(self): relpath = self.hashed_file_path("cached/module.js") - self.assertEqual(relpath, "cached/module.4326210cf0bd.js") + self.assertEqual(relpath, "cached/module.eaa407b94311.js") tests = [ b'export * from "./module_test.477bbebe77f0.js";', b'export { testConst } from "./module_test.477bbebe77f0.js";', |
