1 # -*- coding: utf-8 -*-
3 unit test for streaming interface
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6 :copyright: 2007 by Armin Ronacher.
7 :license: BSD, see LICENSE for more details.
11 test_basic_streaming = r"""
12 >>> tmpl = env.from_string("<ul>{% for item in seq %}<li>{{ loop.index "
13 ... "}} - {{ item }}</li>{%- endfor %}</ul>")
14 >>> stream = tmpl.stream(seq=range(4))
29 test_buffered_streaming = r"""
30 >>> tmpl = env.from_string("<ul>{% for item in seq %}<li>{{ loop.index "
31 ... "}} - {{ item }}</li>{%- endfor %}</ul>")
32 >>> stream = tmpl.stream(seq=range(4))
33 >>> stream.enable_buffering(size=3)
35 u'<ul><li>1 - 0</li><li>2 - 1</li>'
37 u'<li>3 - 2</li><li>4 - 3</li></ul>'
40 test_streaming_behavior = r"""
41 >>> tmpl = env.from_string("")
42 >>> stream = tmpl.stream()
45 >>> stream.enable_buffering(20)
48 >>> stream.disable_buffering()