@@ -602,7 +602,10 @@ class TemplateTests(TestCase):
failures.append("Template test (Cached='%s', TEMPLATE_STRING_IF_INVALID='%s', TEMPLATE_DEBUG=%s): %s -- FAILED. Template loading invoked method that shouldn't have been invoked."%(is_cached,invalid_str,template_debug,name))
try:
output=self.render(test_template,vals)
withwarnings.catch_warnings():
# Ignore deprecations of using the wrong number of variables with the 'for' tag.
failures.append("Template test (Cached='%s', TEMPLATE_STRING_IF_INVALID='%s', TEMPLATE_DEBUG=%s): %s -- FAILED. Template rendering invoked method that shouldn't have been invoked."%(is_cached,invalid_str,template_debug,name))
exceptContextStackException:
...
...
@@ -954,18 +957,21 @@ class TemplateTests(TestCase):
'for-tag-unpack08':("{% for key,value, in items %}{{ key }}:{{ value }}/{% endfor %}",{"items":(('one',1),('two',2))},template.TemplateSyntaxError),
# Ensure that a single loopvar doesn't truncate the list in val.
'for-tag-unpack09':("{% for val in items %}{{ val.0 }}:{{ val.1 }}/{% endfor %}",{"items":(('one',1),('two',2))},"one:1/two:2/"),
# Otherwise, silently truncate if the length of loopvars differs to the length of each set of items.
'for-tag-unpack10':("{% for x,y in items %}{{ x }}:{{ y }}/{% endfor %}",{"items":(('one',1,'carrot'),('two',2,'orange'))},"one:1/two:2/"),
'for-tag-unpack11':("{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}",{"items":(('one',1),('two',2))},("one:1,/two:2,/","one:1,INVALID/two:2,INVALID/")),
'for-tag-unpack12':("{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}",{"items":(('one',1,'carrot'),('two',2))},("one:1,carrot/two:2,/","one:1,carrot/two:2,INVALID/")),
'for-tag-unpack13':("{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}",{"items":(('one',1,'carrot'),('two',2,'cheese'))},("one:1,carrot/two:2,cheese/","one:1,carrot/two:2,cheese/")),
'for-tag-unpack14':("{% for x,y in items %}{{ x }}:{{ y }}/{% endfor %}",{"items":(1,2)},(":/:/","INVALID:INVALID/INVALID:INVALID/")),
'for-tag-empty01':("{% for val in values %}{{ val }}{% empty %}empty text{% endfor %}",{"values":[1,2,3]},"123"),
'for-tag-empty02':("{% for val in values %}{{ val }}{% empty %}values array empty{% endfor %}",{"values":[]},"values array empty"),
'for-tag-empty03':("{% for val in values %}{{ val }}{% empty %}values array not found{% endfor %}",{},"values array not found"),
# Ticket 19882
'for-tag-filter-ws':("{% load custom %}{% for x in s|noop:'x y' %}{{ x }}{% endfor %}",{'s':'abc'},'abc'),
# These tests raise deprecation warnings and will raise an exception
# in Django 2.0. The existing behavior is silent truncation if the
# length of loopvars differs to the length of each set of items.
'for-tag-unpack10':("{% for x,y in items %}{{ x }}:{{ y }}/{% endfor %}",{"items":(('one',1,'carrot'),('two',2,'orange'))},"one:1/two:2/"),
'for-tag-unpack11':("{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}",{"items":(('one',1),('two',2))},("one:1,/two:2,/","one:1,INVALID/two:2,INVALID/")),
'for-tag-unpack12':("{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}",{"items":(('one',1,'carrot'),('two',2))},("one:1,carrot/two:2,/","one:1,carrot/two:2,INVALID/")),
'for-tag-unpack14':("{% for x,y in items %}{{ x }}:{{ y }}/{% endfor %}",{"items":(1,2)},(":/:/","INVALID:INVALID/INVALID:INVALID/")),
### IF TAG ################################################################
'if-tag01':("{% if foo %}yes{% else %}no{% endif %}",{"foo":True},"yes"),
'if-tag02':("{% if foo %}yes{% else %}no{% endif %}",{"foo":False},"no"),