summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/staticfiles_tests/storage.py5
-rw-r--r--tests/staticfiles_tests/test_templatetags.py15
2 files changed, 18 insertions, 2 deletions
diff --git a/tests/staticfiles_tests/storage.py b/tests/staticfiles_tests/storage.py
index cf648f06f2..467217ae53 100644
--- a/tests/staticfiles_tests/storage.py
+++ b/tests/staticfiles_tests/storage.py
@@ -58,6 +58,11 @@ class PathNotImplementedStorage(storage.Storage):
raise NotImplementedError
+class QueryStringStorage(storage.Storage):
+ def url(self, path):
+ return path + '?a=b&c=d'
+
+
class SimpleCachedStaticFilesStorage(CachedStaticFilesStorage):
def file_hash(self, name, content=None):
diff --git a/tests/staticfiles_tests/test_templatetags.py b/tests/staticfiles_tests/test_templatetags.py
index 050f19b179..541b233855 100644
--- a/tests/staticfiles_tests/test_templatetags.py
+++ b/tests/staticfiles_tests/test_templatetags.py
@@ -1,5 +1,7 @@
from __future__ import unicode_literals
+from django.test import override_settings
+
from .cases import StaticFilesTestCase
@@ -8,5 +10,14 @@ class TestTemplateTag(StaticFilesTestCase):
def test_template_tag(self):
self.assertStaticRenders("does/not/exist.png", "/static/does/not/exist.png")
self.assertStaticRenders("testfile.txt", "/static/testfile.txt")
- self.assertStaticRenders("test.html?foo=1&bar=2", "/static/test.html?foo=1&bar=2", autoescape=False)
- self.assertStaticRenders("test.html?foo=1&bar=2", "/static/test.html?foo=1&bar=2", autoescape=True)
+ self.assertStaticRenders("special?chars&quoted.html", "/static/special%3Fchars%26quoted.html")
+
+ @override_settings(STATICFILES_STORAGE='staticfiles_tests.storage.QueryStringStorage')
+ def test_template_tag_escapes(self):
+ """
+ Storage.url() should return an encoded path and might be overridden
+ to also include a querystring. {% static %} escapes the URL to avoid
+ raw '&', for example.
+ """
+ self.assertStaticRenders('a.html', 'a.html?a=b&c=d')
+ self.assertStaticRenders('a.html', 'a.html?a=b&c=d', autoescape=False)