Used assertRaisesMessage() in {% for %} tests.

This commit is contained in:
Tim Graham 2016-12-29 11:10:02 -05:00
parent 7d14889aa3
commit 9f16ea21c4
1 changed files with 6 additions and 3 deletions

View File

@ -71,17 +71,20 @@ class ForTagTests(SimpleTestCase):
@setup({'for-tag-unpack06': '{% for key value in items %}{{ key }}:{{ value }}/{% endfor %}'})
def test_for_tag_unpack06(self):
with self.assertRaises(TemplateSyntaxError):
msg = "'for' tag received an invalid argument: for key value in items"
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.render_to_string('for-tag-unpack06', {'items': (('one', 1), ('two', 2))})
@setup({'for-tag-unpack07': '{% for key,,value in items %}{{ key }}:{{ value }}/{% endfor %}'})
def test_for_tag_unpack07(self):
with self.assertRaises(TemplateSyntaxError):
msg = "'for' tag received an invalid argument: for key,,value in items"
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.render_to_string('for-tag-unpack07', {'items': (('one', 1), ('two', 2))})
@setup({'for-tag-unpack08': '{% for key,value, in items %}{{ key }}:{{ value }}/{% endfor %}'})
def test_for_tag_unpack08(self):
with self.assertRaises(TemplateSyntaxError):
msg = "'for' tag received an invalid argument: for key,value, in items"
with self.assertRaisesMessage(TemplateSyntaxError, msg):
self.engine.render_to_string('for-tag-unpack08', {'items': (('one', 1), ('two', 2))})
@setup({'for-tag-unpack09': '{% for val in items %}{{ val.0 }}:{{ val.1 }}/{% endfor %}'})