summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPreston Holmes <preston@ptone.com>2013-02-24 08:10:33 -0800
committerPreston Holmes <preston@ptone.com>2013-02-24 08:10:33 -0800
commite369dc28075b4331c125494fe7bd73855d73a0ce (patch)
tree3c53b59753c0c48c6e1b4e35573d22fcfcbd36d9 /tests
parentd5462596478992075fd04705fedd6a3cca49fae8 (diff)
parent636c45fc58bcc19d7669a739ccd05ff475381f48 (diff)
Merge pull request #832 from chrismedrela/ticket19890
Fixed #19890 -- ifchanged templatetag rendered its content twice
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()