mirror of
https://github.com/home-assistant/core.git
synced 2026-09-28 02:18:10 -04:00
Log deprecation warning when template.Template is created without hass (#125142)
* Log deprecation warning when template.Template is created without hass * Improve docstring
This commit is contained in:
@@ -6281,3 +6281,20 @@ def test_unzip(hass: HomeAssistant, col, expected) -> None:
|
||||
).async_render({"col": col})
|
||||
== expected
|
||||
)
|
||||
|
||||
|
||||
def test_warn_no_hass(hass: HomeAssistant, caplog: pytest.LogCaptureFixture) -> None:
|
||||
"""Test deprecation warning when instantiating Template without hass."""
|
||||
|
||||
message = "Detected code that creates a template object without passing hass"
|
||||
template.Template("blah")
|
||||
assert message in caplog.text
|
||||
caplog.clear()
|
||||
|
||||
template.Template("blah", None)
|
||||
assert message in caplog.text
|
||||
caplog.clear()
|
||||
|
||||
template.Template("blah", hass)
|
||||
assert message not in caplog.text
|
||||
caplog.clear()
|
||||
|
||||
Reference in New Issue
Block a user