Fixed a test that was failing in Python 3.

The issue was that as of Python 3, the generators' `next()`
method becomes `__next()`. Thanks Alex Gaynor for noticing that.
Refs #19890.
This commit is contained in:
Julien Phalip 2013-02-24 13:47:14 -08:00
parent a8449d4362
commit ae2a8bb456
1 changed files with 3 additions and 8 deletions

View File

@ -444,14 +444,9 @@ class Templates(TestCase):
def test_ifchanged_render_once(self): def test_ifchanged_render_once(self):
""" Test for ticket #19890. The content of ifchanged template tag was """ Test for ticket #19890. The content of ifchanged template tag was
rendered twice.""" rendered twice."""
template = Template('{% ifchanged %}{% cycle "1st time" "2nd time" %}{% endifchanged %}')
template = Template('{% ifchanged %}{{ gen.next }}{% endifchanged %}') output = template.render(Context({}))
def gen(): self.assertEqual(output, '1st time')
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): def test_templates(self):
template_tests = self.get_template_tests() template_tests = self.get_template_tests()