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

Method test_callable_defaults

tests/test_regression.py:352–363  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

350 assert tmpl.render().strip() == "0123456789"
351
352 def test_callable_defaults(self):
353 env = Environment()
354 env.globals["get_int"] = lambda: 42
355 t = env.from_string(
356 """
357 {% macro test(a, b, c=get_int()) -%}
358 {{ a + b + c }}
359 {%- endmacro %}
360 {{ test(1, 2) }}|{{ test(1, 2, 3) }}
361 """
362 )
363 assert t.render().strip() == "45|6"
364
365 def test_macro_escaping(self):
366 env = Environment(autoescape=lambda x: False)

Callers

nothing calls this directly

Calls 3

from_stringMethod · 0.95
EnvironmentClass · 0.90
renderMethod · 0.45

Tested by

no test coverage detected