Skip to content
Myr

test_streaming.py

This file

Path

tests/test_streaming.py

51 lines · 1.2 KiB · Python

Last changed by

Copyright switch to "The Jinja Team".Armin Ronacherbefore adoption62ccd1b

History of this file

Take it

The walk stopped after 200 commits: lines older than b217886 point at it.

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 1–5why, one step back
1# -*- coding: utf-8 -*-
2"""3 unit test for streaming interface4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~5

Copyright switch to "The Jinja Team".Armin Ronacherbefore adoption62ccd1b

line 6why, one step back
6 :copyright: (c) 2009 by the Jinja Team.

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 7–51why, one step back
7 :license: BSD, see LICENSE for more details.
8"""91011test_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))15>>> stream.next()16u'<ul>'17>>> stream.next()18u'<li>1 - 0</li>'19>>> stream.next()20u'<li>2 - 1</li>'21>>> stream.next()22u'<li>3 - 2</li>'23>>> stream.next()24u'<li>4 - 3</li>'25>>> stream.next()26u'</ul>'27"""2829test_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)34>>> stream.next()35u'<ul><li>1 - 0</li><li>2 - 1</li>'36>>> stream.next()37u'<li>3 - 2</li><li>4 - 3</li></ul>'38"""3940test_streaming_behavior = r"""41>>> tmpl = env.from_string("")42>>> stream = tmpl.stream()43>>> stream.buffered44False45>>> stream.enable_buffering(20)46>>> stream.buffered47True48>>> stream.disable_buffering()49>>> stream.buffered50False51"""