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

Method test_invalid_required

tests/test_inheritance.py:286–317  ·  tests/test_inheritance.py::TestInheritance.test_invalid_required
(self, env)

Source from the content-addressed store, hash-verified

284 assert t3.render() == class="st">"[2]"
285
286 def test_invalid_required(self, env):
287 env = Environment(
288 loader=DictLoader(
289 {
290 class="st">"empty": class="st">"{% block x required %}{% endblock %}",
291 class="st">"blank": class="st">"{% block x required %} {class="cm"># c #}{% endblock %}",
292 class="st">"text": class="st">"{% block x required %}data {class="cm"># c #}{% endblock %}",
293 class="st">"block": class="st">"{% block x required %}{% block y %}"
294 class="st">"{% endblock %}{% endblock %}",
295 class="st">"if": class="st">"{% block x required %}{% if true %}"
296 class="st">"{% endif %}{% endblock %}",
297 class="st">"top": class="st">"{% extends t %}{% block x %}CHILD{% endblock %}",
298 }
299 )
300 )
301 t = env.get_template(class="st">"top")
302 assert t.render(t=class="st">"empty") == class="st">"CHILD"
303 assert t.render(t=class="st">"blank") == class="st">"CHILD"
304
305 required_block_check = pytest.raises(
306 TemplateSyntaxError,
307 match=class="st">"Required blocks can only contain comments or whitespace",
308 )
309
310 with required_block_check:
311 t.render(t=class="st">"text")
312
313 with required_block_check:
314 t.render(t=class="st">"block")
315
316 with required_block_check:
317 t.render(t=class="st">"if")
318
319 def test_required_with_scope(self, env):
320 env = Environment(

Callers

nothing calls this directly

Calls 4

get_templateMethod · 0.95
EnvironmentClass · 0.90
DictLoaderClass · 0.90
renderMethod · 0.45

Tested by

no test coverage detected