Skip to content
Myr

Fixed #79

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

authored by Armin Ronacher · committed by Armin Ronacher · parent 9417d01 · Browse files · 2 files+27 added−3 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+27 added−3 removed

  • other:+27 added−3 removed

2 files+27 added−3 removed

modified:jinja2/testsuite/inheritance.py+25 added-2 removed
10 unmodified lines
11import unittest1213from jinja2.testsuite import JinjaTestCase1415from jinja2 import Environment, DictLoader15from jinja2 import Environment, DictLoader, TemplateError161718LAYOUTTEMPLATE = '''\19|{% block block1 %}block 1 from layout{% endblock %}
32 unmodified lines
52 {% endif %}53{% endblock %}54'''5556DOUBLEEXTENDS = '''\57{% extends "layout" %}58{% extends "layout" %}59{% block block1 %}60 {% if false %}61 {% block block2 %}62 this should workd63 {% endblock %}64 {% endif %}65{% endblock %}66'''676869env = Environment(loader=DictLoader({70 'layout': LAYOUTTEMPLATE,71 'level1': LEVEL1TEMPLATE,72 'level2': LEVEL2TEMPLATE,73 'level3': LEVEL3TEMPLATE,74 'level4': LEVEL4TEMPLATE,62 'working': WORKINGTEMPLATE75 'working': WORKINGTEMPLATE,76 'doublee': DOUBLEEXTENDS,77}), trim_blocks=True)787980class InheritanceTestCase(JinjaTestCase):
151 unmodified lines
232 {% block content %} {% endblock %}233 '''234 })).get_template("test.html").render().split() == [u'outer_box', u'my_macro']235236 def test_double_extends(self):237 """Ensures that a template with more than 1 {% extends ... %} usage238 raises a ``TemplateError``.239 """240 try:241 tmpl = env.get_template('doublee')242 except Exception, e:243 assert isinstance(e, TemplateError)244245246def suite():247 suite = unittest.TestSuite()248 suite.addTest(unittest.makeSuite(InheritanceTestCase))249 suite.addTest(unittest.makeSuite(BugFixTestCase))
1 unmodified line
modified:jinja2/compiler.py+2 added-1 removed
890 unmodified lines
891 self.writeline('if parent_template is not None:')892 self.indent()893 self.writeline('raise TemplateRuntimeError(%r)' %894 'extended multiple times')895 self.outdent()895896 # if we have a known extends already we don't need that code here897 # as we know that the template execution will end here.898 if self.has_known_extends:899 raise CompilerExit()900 else:901 self.outdent()902903 self.writeline('parent_template = environment.get_template(', node)904 self.visit(node.template, frame)905 self.write(', %r)' % self.name)
735 unmodified lines