summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/staticfiles_tests')
-rw-r--r--tests/staticfiles_tests/project/documents/absolute_root.css1
-rw-r--r--tests/staticfiles_tests/project/documents/cached/absolute.css1
-rw-r--r--tests/staticfiles_tests/project/documents/styles_root.css1
-rw-r--r--tests/staticfiles_tests/test_storage.py15
4 files changed, 17 insertions, 1 deletions
diff --git a/tests/staticfiles_tests/project/documents/absolute_root.css b/tests/staticfiles_tests/project/documents/absolute_root.css
new file mode 100644
index 0000000000..b35ff47c9e
--- /dev/null
+++ b/tests/staticfiles_tests/project/documents/absolute_root.css
@@ -0,0 +1 @@
+@import url("/static/styles_root.css");
diff --git a/tests/staticfiles_tests/project/documents/cached/absolute.css b/tests/staticfiles_tests/project/documents/cached/absolute.css
index 03f2ae791a..6a2040b413 100644
--- a/tests/staticfiles_tests/project/documents/cached/absolute.css
+++ b/tests/staticfiles_tests/project/documents/cached/absolute.css
@@ -1,4 +1,5 @@
@import url("/static/cached/styles.css");
+@import url("/static/styles_root.css");
body {
background: #d3d6d8 url(/static/cached/img/relative.png);
}
diff --git a/tests/staticfiles_tests/project/documents/styles_root.css b/tests/staticfiles_tests/project/documents/styles_root.css
new file mode 100644
index 0000000000..64512630cb
--- /dev/null
+++ b/tests/staticfiles_tests/project/documents/styles_root.css
@@ -0,0 +1 @@
+/* see cached/absolute.css and absolute_root.css */
diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py
index f0c69cebe6..9de5a28223 100644
--- a/tests/staticfiles_tests/test_storage.py
+++ b/tests/staticfiles_tests/test_storage.py
@@ -96,13 +96,26 @@ class TestHashedFiles(object):
def test_template_tag_absolute(self):
relpath = self.hashed_file_path("cached/absolute.css")
- self.assertEqual(relpath, "cached/absolute.ae9ef2716fe3.css")
+ self.assertEqual(relpath, "cached/absolute.df312c6326e1.css")
with storage.staticfiles_storage.open(relpath) as relfile:
content = relfile.read()
self.assertNotIn(b"/static/cached/styles.css", content)
self.assertIn(b"/static/cached/styles.bb84a0240107.css", content)
+ self.assertNotIn(b"/static/styles_root.css", content)
+ self.assertIn(b"/static/styles_root.401f2509a628.css", content)
self.assertIn(b'/static/cached/img/relative.acae32e4532b.png', content)
+ def test_template_tag_absolute_root(self):
+ """
+ Like test_template_tag_absolute, but for a file in STATIC_ROOT (#26249).
+ """
+ relpath = self.hashed_file_path("absolute_root.css")
+ self.assertEqual(relpath, "absolute_root.f864a4d7f083.css")
+ with storage.staticfiles_storage.open(relpath) as relfile:
+ content = relfile.read()
+ self.assertNotIn(b"/static/styles_root.css", content)
+ self.assertIn(b"/static/styles_root.401f2509a628.css", content)
+
def test_template_tag_denorm(self):
relpath = self.hashed_file_path("cached/denorm.css")
self.assertEqual(relpath, "cached/denorm.c5bd139ad821.css")