diff options
author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-01-10 21:35:09 +0100 |
---|---|---|
committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-01-12 21:01:34 +0100 |
commit | 71b7668b75d10589bbbdc7c5ca9ee7a125f91c90 (patch) | |
tree | c6535d740e9826a936608208d003f7f3b33ede17 /tests/template_backends | |
parent | 4c413e231cfe788de6e371567f395c8ccbd26103 (diff) | |
download | django-71b7668b75d10589bbbdc7c5ca9ee7a125f91c90.tar.gz |
Rewrapped TemplateSyntaxError in Jinja2 backend.
Changed import style to avoid confusion between Django's and Jinja2's
APIs.
Diffstat (limited to 'tests/template_backends')
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>'} |