From 31e053edfa01e47c26dfa03834beeba77e09403a Mon Sep 17 00:00:00 2001 From: Alexander Schrijver Date: Sat, 16 Jul 2016 22:54:08 +0200 Subject: [PATCH] Refs #26830 -- Added a test for a named cycle template tag inside an ifchanged block and a for loop. --- .../template_tests/syntax_tests/test_cycle.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/template_tests/syntax_tests/test_cycle.py b/tests/template_tests/syntax_tests/test_cycle.py index 13073ef26d..e98a7ec509 100644 --- a/tests/template_tests/syntax_tests/test_cycle.py +++ b/tests/template_tests/syntax_tests/test_cycle.py @@ -127,3 +127,21 @@ class CycleTagTests(SimpleTestCase): def test_cycle28(self): output = self.engine.render_to_string('cycle28', {'a': '<', 'b': '>'}) self.assertEqual(output, '<>') + + @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')