From 71b7668b75d10589bbbdc7c5ca9ee7a125f91c90 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sat, 10 Jan 2015 21:35:09 +0100 Subject: Rewrapped TemplateSyntaxError in Jinja2 backend. Changed import style to avoid confusion between Django's and Jinja2's APIs. --- .../jinja2/template_backends/syntax_error.html | 1 + .../templates/template_backends/syntax_error.html | 1 + tests/template_backends/test_dummy.py | 10 +++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/template_backends/jinja2/template_backends/syntax_error.html create mode 100644 tests/template_backends/templates/template_backends/syntax_error.html (limited to 'tests') 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': ''} -- cgit v1.3