mirror of https://github.com/django/django.git
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
from django.conf import STATICFILES_STORAGE_ALIAS
|
|
from django.test import override_settings
|
|
|
|
from .cases import StaticFilesTestCase
|
|
|
|
|
|
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(
|
|
"special?chars"ed.html", "/static/special%3Fchars%26quoted.html"
|
|
)
|
|
|
|
@override_settings(
|
|
STORAGES={
|
|
STATICFILES_STORAGE_ALIAS: {
|
|
"BACKEND": "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)
|