summaryrefslogtreecommitdiff
path: root/tests/template_tests/syntax_tests
diff options
context:
space:
mode:
authorDave Smith <dsmith@hirevue.com>2015-09-10 21:05:00 -0600
committerTim Graham <timograham@gmail.com>2015-09-15 12:25:13 -0400
commitb53b4d5c107dbd56386c599582f46c522877a651 (patch)
tree422e60fa254a59be72a122cf7d6ee2dc933a1bb7 /tests/template_tests/syntax_tests
parentd731cf5caf043189fda3708cc0dace5d8f94db6b (diff)
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.
Diffstat (limited to 'tests/template_tests/syntax_tests')
-rw-r--r--tests/template_tests/syntax_tests/test_basic.py8
-rw-r--r--tests/template_tests/syntax_tests/test_filter_syntax.py11
2 files changed, 14 insertions, 5 deletions
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')
diff --git a/tests/template_tests/syntax_tests/test_filter_syntax.py b/tests/template_tests/syntax_tests/test_filter_syntax.py
index 1793fc67de..e9f0491d6e 100644
--- a/tests/template_tests/syntax_tests/test_filter_syntax.py
+++ b/tests/template_tests/syntax_tests/test_filter_syntax.py
@@ -71,9 +71,18 @@ class FilterSyntaxTests(SimpleTestCase):
"""
Raise TemplateSyntaxError for empty block tags
"""
- with self.assertRaises(TemplateSyntaxError):
+ with self.assertRaisesMessage(TemplateSyntaxError, 'Empty block tag on line 1'):
self.engine.get_template('filter-syntax08')
+ @setup({'filter-syntax08-multi-line': "line 1\nline 2\nline 3{% %}\nline 4\nline 5"})
+ def test_filter_syntax08_multi_line(self):
+ """
+ Raise TemplateSyntaxError for empty block tags in templates with
+ multiple lines.
+ """
+ with self.assertRaisesMessage(TemplateSyntaxError, 'Empty block tag on line 3'):
+ self.engine.get_template('filter-syntax08-multi-line')
+
@setup({'filter-syntax09': '{{ var|cut:"o"|upper|lower }}'})
def test_filter_syntax09(self):
"""