From b53b4d5c107dbd56386c599582f46c522877a651 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Thu, 10 Sep 2015 21:05:00 -0600 Subject: 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. --- tests/template_tests/syntax_tests/test_basic.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/template_tests/syntax_tests/test_basic.py') diff --git a/tests/template_tests/syntax_tests/test_basic.py b/tests/template_tests/syntax_tests/test_basic.py index da45fe2839..0a1c10cee8 100644 --- a/tests/template_tests/syntax_tests/test_basic.py +++ b/tests/template_tests/syntax_tests/test_basic.py @@ -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') -- cgit v1.3