1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Rewrapped TemplateSyntaxError in Jinja2 backend.

Changed import style to avoid confusion between Django's and Jinja2's
APIs.
This commit is contained in:
Aymeric Augustin
2015-01-10 21:35:09 +01:00
parent 4c413e231c
commit 71b7668b75
4 changed files with 19 additions and 7 deletions

View File

@@ -4,7 +4,7 @@ from __future__ import unicode_literals
from django.http import HttpRequest
from django.middleware.csrf import CsrfViewMiddleware, get_token
from django.template import TemplateDoesNotExist
from django.template import TemplateDoesNotExist, TemplateSyntaxError
from django.template.backends.dummy import TemplateStrings
from django.test import SimpleTestCase
@@ -39,6 +39,14 @@ class TemplateStringsTests(SimpleTestCase):
with self.assertRaises(TemplateDoesNotExist):
self.engine.get_template('template_backends/non_existing.html')
def test_get_template_syntax_error(self):
# There's no way to trigger a syntax error with the dummy backend.
# The test still lives here to factor it between other backends.
if self.backend_name == 'dummy':
return
with self.assertRaises(TemplateSyntaxError):
self.engine.get_template('template_backends/syntax_error.html')
def test_html_escaping(self):
template = self.engine.get_template('template_backends/hello.html')
context = {'name': '<script>alert("XSS!");</script>'}