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

Method test_get_template_undefined

tests/test_api.py:112–133  ·  view source on GitHub ↗

Passing Undefined to get/select_template raises an UndefinedError or shows the undefined message in the list.

(self, env)

Source from the content-addressed store, hash-verified

110 assert env.get_or_select_template(t) is t
111
112 def test_get_template_undefined(self, env):
113 """Passing Undefined to get/select_template raises an
114 UndefinedError or shows the undefined message in the list.
115 """
116 env.loader = DictLoader({})
117 t = Undefined(name="no_name_1")
118
119 with pytest.raises(UndefinedError):
120 env.get_template(t)
121
122 with pytest.raises(UndefinedError):
123 env.get_or_select_template(t)
124
125 with pytest.raises(UndefinedError):
126 env.select_template(t)
127
128 with pytest.raises(TemplatesNotFound) as exc_info:
129 env.select_template([t, "no_name_2"])
130
131 exc_message = str(exc_info.value)
132 assert "'no_name_1' is undefined" in exc_message
133 assert "no_name_2" in exc_message
134
135 def test_autoescape_autoselect(self, env):
136 def select_autoescape(name):

Callers

nothing calls this directly

Calls 5

DictLoaderClass · 0.90
UndefinedClass · 0.90
get_templateMethod · 0.80
select_templateMethod · 0.80

Tested by

no test coverage detected