def test_basic_streaming(self):
tmpl = env.from_string("<ul>{% for item in seq %}<li>{{ loop.index "
"}} - {{ item }}</li>{%- endfor %}</ul>")
stream = tmpl.stream(seq=list(range(4)))
self.assert_equal(next(stream), '<ul>')
self.assert_equal(next(stream), '<li>1 - 0</li>')
self.assert_equal(next(stream), '<li>2 - 1</li>')
self.assert_equal(next(stream), '<li>3 - 2</li>')
self.assert_equal(next(stream), '<li>4 - 3</li>')
self.assert_equal(next(stream), '</ul>')
评论列表
文章目录