]
+@pytest.mark.ext
+class TestScope(object):
+
+ def test_basic_scope_behavior(self):
+ # This is what the old with statement compiled down to
+ class ScopeExt(Extension):
+ tags = set(['scope'])
+
+ def parse(self, parser):
+ node = nodes.Scope(lineno=next(parser.stream).lineno)
+ assignments = []
+ while parser.stream.current.type != 'block_end':
+ lineno = parser.stream.current.lineno
+ if assignments:
+ parser.stream.expect('comma')
+ target = parser.parse_assign_target()
+ parser.stream.expect('assign')
+ expr = parser.parse_expression()
+ assignments.append(nodes.Assign(target, expr, lineno=lineno))
+ node.body = assignments + \
+ list(parser.parse_statements(('name:endscope',),
+ drop_needle=True))
+ return node
+
+ env = Environment(extensions=[ScopeExt])
+ tmpl = env.from_string('''\
+ {%- with a=1, b=2, c=b, d=e, e=5 -%}
+ {{ a }}|{{ b }}|{{ c }}|{{ d }}|{{ e }}
+ {%- endwith -%}
+ ''')
+ assert tmpl.render(b=3, e=4) == '1|2|2|4|5'
+
+
@pytest.mark.ext
class TestNewstyleInternationalization(object):