Skip to content
Myr

added two more unittests for inheritance

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 4f5008f · Browse files · 2 files+33 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+33 added−0 removed

  • tests:+33 added−0 removed

2 files+33 added−0 removed

modified:tests/test_inheritance.py+24 added
105 unmodified lines
106 'b': '{% extends "a" %}{% block x %}B{{ super() }}{% endblock %}'107 }))108 tmpl = env.get_template('b')109 assert tmpl.render() == 'BA'110111112def test_dynamic_inheritance():113 env = Environment(loader=DictLoader({114 'master1': 'MASTER1{% block x %}{% endblock %}',115 'master2': 'MASTER2{% block x %}{% endblock %}',116 'child': '{% extends master %}{% block x %}CHILD{% endblock %}'117 }))118 tmpl = env.get_template('child')119 for m in range(1, 3):120 assert tmpl.render(master='master%d' % m) == 'MASTER%dCHILD' % m121122123def test_multi_inheritance():124 env = Environment(loader=DictLoader({125 'master1': 'MASTER1{% block x %}{% endblock %}',126 'master2': 'MASTER2{% block x %}{% endblock %}',127 'child': '''{% if master %}{% extends master %}{% else %}{% extends128 'master1' %}{% endif %}{% block x %}CHILD{% endblock %}'''129 }))130 tmpl = env.get_template('child')131 assert tmpl.render(master='master2') == 'MASTER2CHILD'132 assert tmpl.render(master='master1') == 'MASTER1CHILD'133 assert tmpl.render() == 'MASTER1CHILD'
modified:tests/test_lexer.py+9 added
56 unmodified lines
57 continue58 stream = env.lexer.tokenize('{{ %s }}' % test)59 stream.next()60 assert stream.current.type == expect616263def test_normalizing():64 from jinja2 import Environment65 for seq in '\r', '\r\n', '\n':66 env = Environment(newline_sequence=seq)67 tmpl = env.from_string('1\n2\r\n3\n4\n')68 result = tmpl.render()69 assert result.replace(seq, 'X') == '1X2X3X4'