Refs #26830 -- Added a test for a named cycle template tag inside an ifchanged block and a for loop.

This commit is contained in:
Alexander Schrijver 2016-07-16 22:54:08 +02:00 committed by Tim Graham
parent f95bd89e82
commit 31e053edfa
1 changed files with 18 additions and 0 deletions

View File

@ -127,3 +127,21 @@ class CycleTagTests(SimpleTestCase):
def test_cycle28(self):
output = self.engine.render_to_string('cycle28', {'a': '<', 'b': '>'})
self.assertEqual(output, '<&gt;')
@setup({
'cycle29': "{% cycle 'a' 'b' 'c' as cycler silent %}"
"{% for x in values %}"
"{% ifchanged x %}"
"{% cycle cycler %}{{ cycler }}"
"{% else %}"
"{{ cycler }}"
"{% endifchanged %}"
"{% endfor %}"
})
def test_cycle29(self):
"""
A named {% cycle %} tag works inside an {% ifchanged %} block and a
{% for %} loop.
"""
output = self.engine.render_to_string('cycle29', {'values': [1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 9, 9]})
self.assertEqual(output, 'bcabcabcccaa')