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:
@@ -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>'}
|
||||
|
||||
Reference in New Issue
Block a user