Passing Undefined to get/select_template raises an UndefinedError or shows the undefined message in the list.
(self, env)
| 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): |
nothing calls this directly
no test coverage detected