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

Fixed #25404 -- Added line numbers to TemplateSyntaxError strings.

This makes it much easier to diagnose a test failure when all
you have is the stack trace from an uncaught TemplateSyntaxError.
This commit is contained in:
Dave Smith
2015-09-10 21:05:00 -06:00
committed by Tim Graham
parent d731cf5caf
commit b53b4d5c10
4 changed files with 31 additions and 12 deletions

View File

@@ -61,7 +61,7 @@ class BasicSyntaxTests(SimpleTestCase):
"""
Raise TemplateSyntaxError for empty variable tags.
"""
with self.assertRaises(TemplateSyntaxError):
with self.assertRaisesMessage(TemplateSyntaxError, 'Empty variable tag on line 1'):
self.engine.get_template('basic-syntax07')
@setup({'basic-syntax08': '{{ }}'})
@@ -69,7 +69,7 @@ class BasicSyntaxTests(SimpleTestCase):
"""
Raise TemplateSyntaxError for empty variable tags.
"""
with self.assertRaises(TemplateSyntaxError):
with self.assertRaisesMessage(TemplateSyntaxError, 'Empty variable tag on line 1'):
self.engine.get_template('basic-syntax08')
@setup({'basic-syntax09': '{{ var.method }}'})
@@ -314,13 +314,13 @@ class BasicSyntaxTests(SimpleTestCase):
@setup({'template': '{% block content %}'})
def test_unclosed_block(self):
msg = "Unclosed tag 'block'. Looking for one of: endblock."
msg = "Unclosed tag on line 1: 'block'. Looking for one of: endblock."
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.render_to_string('template')
@setup({'template': '{% if a %}'})
def test_unclosed_block2(self):
msg = "Unclosed tag 'if'. Looking for one of: elif, else, endif."
msg = "Unclosed tag on line 1: 'if'. Looking for one of: elif, else, endif."
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.render_to_string('template')