diff options
author | Armin Ronacher <armin.ronacher@active-4.com> | 2008-05-23 23:43:45 +0200 |
---|---|---|
committer | Armin Ronacher <armin.ronacher@active-4.com> | 2008-05-23 23:43:45 +0200 |
commit | be1dca1143abe7784be7c5ca4a626fd184670d8b (patch) | |
tree | acc13d594efe6757af9cfeea219f54f3b49dc518 /tests/test_inheritance.py | |
parent | 4f5008ff1917356e0d71bedc96546cf0c5db834d (diff) | |
download | jinja2-be1dca1143abe7784be7c5ca4a626fd184670d8b.tar.gz |
added two more unittests for inheritance
--HG--
branch : trunk
Diffstat (limited to 'tests/test_inheritance.py')
-rw-r--r-- | tests/test_inheritance.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_inheritance.py b/tests/test_inheritance.py index ee8296a..8884b9f 100644 --- a/tests/test_inheritance.py +++ b/tests/test_inheritance.py @@ -107,3 +107,27 @@ def test_preserve_blocks(): })) tmpl = env.get_template('b') assert tmpl.render() == 'BA' + + +def test_dynamic_inheritance(): + env = Environment(loader=DictLoader({ + 'master1': 'MASTER1{% block x %}{% endblock %}', + 'master2': 'MASTER2{% block x %}{% endblock %}', + 'child': '{% extends master %}{% block x %}CHILD{% endblock %}' + })) + tmpl = env.get_template('child') + for m in range(1, 3): + assert tmpl.render(master='master%d' % m) == 'MASTER%dCHILD' % m + + +def test_multi_inheritance(): + env = Environment(loader=DictLoader({ + 'master1': 'MASTER1{% block x %}{% endblock %}', + 'master2': 'MASTER2{% block x %}{% endblock %}', + 'child': '''{% if master %}{% extends master %}{% else %}{% extends + 'master1' %}{% endif %}{% block x %}CHILD{% endblock %}''' + })) + tmpl = env.get_template('child') + assert tmpl.render(master='master2') == 'MASTER2CHILD' + assert tmpl.render(master='master1') == 'MASTER1CHILD' + assert tmpl.render() == 'MASTER1CHILD' |