Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to include a test which fails currently due to issue #79 #123

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 24 additions & 2 deletions jinja2/testsuite/inheritance.py
Expand Up @@ -12,7 +12,7 @@


from jinja2.testsuite import JinjaTestCase from jinja2.testsuite import JinjaTestCase


from jinja2 import Environment, DictLoader from jinja2 import Environment, DictLoader, TemplateError




LAYOUTTEMPLATE = '''\ LAYOUTTEMPLATE = '''\
Expand Down Expand Up @@ -53,13 +53,26 @@
{% endblock %} {% endblock %}
''' '''


DOUBLEEXTENDS = '''\
{% extends "layout" %}
{% extends "layout" %}
{% block block1 %}
{% if false %}
{% block block2 %}
this should workd
{% endblock %}
{% endif %}
{% endblock %}
'''

env = Environment(loader=DictLoader({ env = Environment(loader=DictLoader({
'layout': LAYOUTTEMPLATE, 'layout': LAYOUTTEMPLATE,
'level1': LEVEL1TEMPLATE, 'level1': LEVEL1TEMPLATE,
'level2': LEVEL2TEMPLATE, 'level2': LEVEL2TEMPLATE,
'level3': LEVEL3TEMPLATE, 'level3': LEVEL3TEMPLATE,
'level4': LEVEL4TEMPLATE, 'level4': LEVEL4TEMPLATE,
'working': WORKINGTEMPLATE 'working': WORKINGTEMPLATE,
'doublee': DOUBLEEXTENDS
}), trim_blocks=True) }), trim_blocks=True)




Expand Down Expand Up @@ -105,6 +118,15 @@ def test_super(self):


def test_working(self): def test_working(self):
tmpl = env.get_template('working') tmpl = env.get_template('working')

def test_double_extends(self):
"""
Ensures that a template with more than 1 {% extends ... %} usage raises a ``TemplateError``.
"""
try:
tmpl = env.get_template('doublee')
except Exception, e:
assert isinstance(e, TemplateError)


def test_reuse_blocks(self): def test_reuse_blocks(self):
tmpl = env.from_string('{{ self.foo() }}|{% block foo %}42' tmpl = env.from_string('{{ self.foo() }}|{% block foo %}42'
Expand Down