diff options
Diffstat (limited to 'tests/regressiontests/templates/tests.py')
| -rw-r--r-- | tests/regressiontests/templates/tests.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index 29171ebf08..ea93beb69e 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -114,6 +114,16 @@ class UTF8Class: return u'ŠĐĆŽćžšđ'.encode('utf-8') class Templates(unittest.TestCase): + def setUp(self): + self.old_static_url = settings.STATIC_URL + self.old_media_url = settings.MEDIA_URL + settings.STATIC_URL = u"/static/" + settings.MEDIA_URL = u"/media/" + + def tearDown(self): + settings.STATIC_URL = self.old_static_url + settings.MEDIA_URL = self.old_media_url + def test_loaders_security(self): ad_loader = app_directories.Loader() fs_loader = filesystem.Loader() @@ -1328,24 +1338,28 @@ class Templates(unittest.TestCase): 'autoescape-filtertag01': ("{{ first }}{% filter safe %}{{ first }} x<y{% endfilter %}", {"first": "<a>"}, template.TemplateSyntaxError), # ifqeual compares unescaped vales. - 'autoescape-ifequal01': ('{% ifequal var "this & that" %}yes{% endifequal %}', { "var": "this & that" }, "yes" ), + 'autoescape-ifequal01': ('{% ifequal var "this & that" %}yes{% endifequal %}', { "var": "this & that" }, "yes"), # Arguments to filters are 'safe' and manipulate their input unescaped. 'autoescape-filters01': ('{{ var|cut:"&" }}', { "var": "this & that" }, "this that" ), - 'autoescape-filters02': ('{{ var|join:" & \" }}', { "var": ("Tom", "Dick", "Harry") }, "Tom & Dick & Harry" ), + 'autoescape-filters02': ('{{ var|join:" & \" }}', { "var": ("Tom", "Dick", "Harry") }, "Tom & Dick & Harry"), # Literal strings are safe. - 'autoescape-literals01': ('{{ "this & that" }}',{}, "this & that" ), + 'autoescape-literals01': ('{{ "this & that" }}',{}, "this & that"), # Iterating over strings outputs safe characters. - 'autoescape-stringiterations01': ('{% for l in var %}{{ l }},{% endfor %}', {'var': 'K&R'}, "K,&,R," ), + 'autoescape-stringiterations01': ('{% for l in var %}{{ l }},{% endfor %}', {'var': 'K&R'}, "K,&,R,"), # Escape requirement survives lookup. - 'autoescape-lookup01': ('{{ var.key }}', { "var": {"key": "this & that" }}, "this & that" ), + 'autoescape-lookup01': ('{{ var.key }}', { "var": {"key": "this & that" }}, "this & that"), + # Static template tags + 'static-prefixtag01': ('{% load static %}{% get_static_prefix %}', {}, settings.STATIC_URL), + 'static-prefixtag02': ('{% load static %}{% get_static_prefix as static_prefix %}{{ static_prefix }}', {}, settings.STATIC_URL), + 'static-prefixtag03': ('{% load static %}{% get_media_prefix %}', {}, settings.MEDIA_URL), + 'static-prefixtag04': ('{% load static %}{% get_media_prefix as media_prefix %}{{ media_prefix }}', {}, settings.MEDIA_URL), } - class TemplateTagLoading(unittest.TestCase): def setUp(self): |
