diff options
Diffstat (limited to 'tests')
3 files changed, 11 insertions, 1 deletions
diff --git a/tests/template_backends/jinja2/template_backends/syntax_error.html b/tests/template_backends/jinja2/template_backends/syntax_error.html new file mode 100644 index 0000000000..d4f7a578fc --- /dev/null +++ b/tests/template_backends/jinja2/template_backends/syntax_error.html @@ -0,0 +1 @@ +{% block %} diff --git a/tests/template_backends/templates/template_backends/syntax_error.html b/tests/template_backends/templates/template_backends/syntax_error.html new file mode 100644 index 0000000000..d4f7a578fc --- /dev/null +++ b/tests/template_backends/templates/template_backends/syntax_error.html @@ -0,0 +1 @@ +{% block %} diff --git a/tests/template_backends/test_dummy.py b/tests/template_backends/test_dummy.py index e79dbbe02a..5f9a8dccb3 100644 --- a/tests/template_backends/test_dummy.py +++ b/tests/template_backends/test_dummy.py @@ -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>'} |
