Skip to content
Myr

Added test for the scope node

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 16e4dae · Browse files · 1 file+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

1 file+33 added−0 removed

  • tests:+33 added−0 removed

1 file+33 added−0 removed

modified:tests/test_ext.py+33 added
302 unmodified lines
303 ]304305306@pytest.mark.ext307class TestScope(object):308309 def test_basic_scope_behavior(self):310 # This is what the old with statement compiled down to311 class ScopeExt(Extension):312 tags = set(['scope'])313314 def parse(self, parser):315 node = nodes.Scope(lineno=next(parser.stream).lineno)316 assignments = []317 while parser.stream.current.type != 'block_end':318 lineno = parser.stream.current.lineno319 if assignments:320 parser.stream.expect('comma')321 target = parser.parse_assign_target()322 parser.stream.expect('assign')323 expr = parser.parse_expression()324 assignments.append(nodes.Assign(target, expr, lineno=lineno))325 node.body = assignments + \326 list(parser.parse_statements(('name:endscope',),327 drop_needle=True))328 return node329330 env = Environment(extensions=[ScopeExt])331 tmpl = env.from_string('''\332 {%- with a=1, b=2, c=b, d=e, e=5 -%}333 {{ a }}|{{ b }}|{{ c }}|{{ d }}|{{ e }}334 {%- endwith -%}335 ''')336 assert tmpl.render(b=3, e=4) == '1|2|2|4|5'337338339@pytest.mark.ext340class TestNewstyleInternationalization(object):341342 def test_trans(self):343 tmpl = newstyle_i18n_env.get_template('child.html')
154 unmodified lines