Improve warnings on undefined template errors (#48713)

This commit is contained in:
Erik Montnemery 2021-04-06 21:11:42 +02:00 committed by GitHub
parent 09635678bc
commit 9f5db2ce3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 63 additions and 8 deletions

View file

@ -2503,4 +2503,7 @@ async def test_undefined_variable(hass, caplog):
"""Test a warning is logged on undefined variables."""
tpl = template.Template("{{ no_such_variable }}", hass)
assert tpl.async_render() == ""
assert "Template variable warning: no_such_variable is undefined" in caplog.text
assert (
"Template variable warning: 'no_such_variable' is undefined when rendering '{{ no_such_variable }}'"
in caplog.text
)