MCPcopy
hub / github.com/pallets/jinja / test_stacked_locals_scoping_bug

Method test_stacked_locals_scoping_bug

tests/test_regression.py:163–187  ·  tests/test_regression.py::TestBug.test_stacked_locals_scoping_bug
(self, env)

Source from the content-addressed store, hash-verified

161 assert tmpl.render(b=True) == class="st">"42"
162
163 def test_stacked_locals_scoping_bug(self, env):
164 env = Environment(line_statement_prefix=class="st">"class="cm">#")
165 t = env.from_string(
166 class="st">"""\
167class="cm"># for j in [1, 2]:
168class="cm"># set x = 1
169class="cm"># for i in [1, 2]:
170class="cm"># print x
171class="cm"># if i % 2 == 0:
172class="cm"># set x = x + 1
173class="cm"># endif
174class="cm"># endfor
175class="cm"># endfor
176class="cm"># if a
177class="cm"># print class="st">'A'
178class="cm"># elif b
179class="cm"># print class="st">'B'
180class="cm"># elif c == d
181class="cm"># print class="st">'C'
182class="cm"># else
183class="cm"># print class="st">'D'
184class="cm"># endif
185 class="st">"""
186 )
187 assert t.render(a=0, b=False, c=42, d=42.0) == class="st">"1111C"
188
189 def test_stacked_locals_scoping_bug_twoframe(self, env):
190 t = Template(

Callers

nothing calls this directly

Calls 3

from_stringMethod · 0.95
EnvironmentClass · 0.90
renderMethod · 0.45

Tested by

no test coverage detected