summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristopher Medrela <chris.medrela@gmail.com>2013-02-24 16:49:28 +0100
committerChristopher Medrela <chris.medrela@gmail.com>2013-02-24 16:49:28 +0100
commit636c45fc58bcc19d7669a739ccd05ff475381f48 (patch)
treec0798a50caec5f831d90d28257697a732da2d26a /tests
parent8503120c1024ad7ec2151196a743d6daec21334b (diff)
Fixed #19890 -- ifchanged templatetag rendered its content twice
The content of ifchanged template tag was rendered twice: first time, to compare it with the previous value and the second time, to return the rendered output.
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/templates/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
index 28d85cae9d..e1e448acba 100644
--- a/tests/regressiontests/templates/tests.py
+++ b/tests/regressiontests/templates/tests.py
@@ -441,6 +441,18 @@ class Templates(TestCase):
output1 = template.render(Context({'foo': range(3), 'get_value': lambda: next(gen1)}))
self.assertEqual(output1, '[0,1,2,3]', 'Expected [0,1,2,3] in first template, got {0}'.format(output1))
+ def test_ifchanged_render_once(self):
+ """ Test for ticket #19890. The content of ifchanged template tag was
+ rendered twice."""
+
+ template = Template('{% ifchanged %}{{ gen.next }}{% endifchanged %}')
+ def gen():
+ for i in xrange(1,10):
+ yield 'iteration no %d' % i
+
+ output = template.render(Context({'gen': gen()}))
+ self.assertEqual(output, 'iteration no 1')
+
def test_templates(self):
template_tests = self.get_template_tests()
filter_tests = filters.get_filter_tests()