Skip to content
Myr

test_old_bugs.py

This file

Path

tests/test_old_bugs.py

62 lines · 1.7 KiB · Python

Last changed by

Added testcase for #335Armin Ronacherbefore adoption1dcafe5

History of this file

Take it

Fixed a bug in constant folding of keyword arguments to filter calls. Thanks noskolo.Armin Ronacherbefore adoption335b87a

lines 1–7why, one step back
1# -*- coding: utf-8 -*-
2"""3 Tests for old bugs4 ~~~~~~~~~~~~~~~~~~56 Unittest that test situations caused by various older bugs.7

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

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

Fixed a bug in constant folding of keyword arguments to filter calls. Thanks noskolo.Armin Ronacherbefore adoption335b87a

lines 9–10why, one step back
9 :license: BSD.
10"""

Added testcase for #335Armin Ronacherbefore adoption1dcafe5

lines 11–12why, one step back
11from py.test import raises
12from jinja2 import Environment, DictLoader, TemplateSyntaxError

Fixed a bug in constant folding of keyword arguments to filter calls. Thanks noskolo.Armin Ronacherbefore adoption335b87a

line 13why, one step back
13

The hopefully final fix for the bug apollo13 spotted earlier.Armin Ronacherbefore adoption7966895

line 14why, one step back
14

Fixed a bug in constant folding of keyword arguments to filter calls. Thanks noskolo.Armin Ronacherbefore adoption335b87a

lines 15–20why, one step back
15def test_keyword_folding():
16 env = Environment()17 env.filters['testing'] = lambda value, some: value + some18 assert env.from_string("{{ 'test'|testing(some='stuff') }}") \19 .render() == 'teststuff'20

The hopefully final fix for the bug apollo13 spotted earlier.Armin Ronacherbefore adoption7966895

lines 21–31why, one step back
21
22def test_extends_output_bugs():23 env = Environment(loader=DictLoader({24 'parent.html': '(({% block title %}{% endblock %}))'25 }))2627 t = env.from_string('{% if expr %}{% extends "parent.html" %}{% endif %}'28 '[[{% block title %}title{% endblock %}]]'29 '{% for item in [1, 2, 3] %}({{ item }}){% endfor %}')30 assert t.render(expr=False) == '[[title]](1)(2)(3)'31 assert t.render(expr=True) == '((title))'

Fixed an escaping bug in urlizeArmin Ronacherbefore adoptiond9342dc

lines 32–36why, one step back
32
3334def test_urlize_filter_escaping(env):35 tmpl = env.from_string('{{ "http://www.example.org/<foo"|urlize }}')36 assert tmpl.render() == '<a href="http://www.example.org/&lt;foo">http://www.example.org/&lt;foo</a>'

Added testcase for a bugArmin Ronacherbefore adoption02b42a8

lines 37–56why, one step back
37
3839def test_loop_call_loop(env):40 tmpl = env.from_string('''4142 {% macro test() %}43 {{ caller() }}44 {% endmacro %}4546 {% for num1 in range(5) %}47 {% call test() %}48 {% for num2 in range(10) %}49 {{ loop.index }}50 {% endfor %}51 {% endcall %}52 {% endfor %}5354 ''')5556 assert tmpl.render() == ''

Added testcase for #335Armin Ronacherbefore adoption1dcafe5

lines 57–62why, one step back
57
5859def test_weird_inline_comment():60 env = Environment(line_statement_prefix='%')61 raises(TemplateSyntaxError, env.from_string,62 '% for item in seq {# missing #}\n...% endfor')