|
22 | 22 | HomeAssistant, |
23 | 23 | callback, |
24 | 24 | ) |
25 | | -from homeassistant.exceptions import TemplateError |
| 25 | +from homeassistant.exceptions import HomeAssistantError, TemplateError |
26 | 26 | from homeassistant.helpers.device_registry import EVENT_DEVICE_REGISTRY_UPDATED |
27 | 27 | from homeassistant.helpers.entity_registry import EVENT_ENTITY_REGISTRY_UPDATED |
28 | 28 | from homeassistant.helpers.event import ( |
@@ -4975,43 +4975,25 @@ def on_state_report(event: Event[EventStateReportedData]) -> None: |
4975 | 4975 | } |
4976 | 4976 |
|
4977 | 4977 |
|
4978 | | -async def test_async_track_template_no_hass_deprecated( |
4979 | | - hass: HomeAssistant, caplog: pytest.LogCaptureFixture |
4980 | | -) -> None: |
4981 | | - """Test async_track_template with a template without hass is deprecated.""" |
4982 | | - message = ( |
4983 | | - "Detected code that calls async_track_template_result with template without " |
4984 | | - "hass. This will stop working in Home Assistant 2025.10, please " |
4985 | | - "report this issue" |
4986 | | - ) |
| 4978 | +async def test_async_track_template_no_hass_fails(hass: HomeAssistant) -> None: |
| 4979 | + """Test async_track_template with a template without hass now fails.""" |
| 4980 | + message = "Calls async_track_template_result with template without hass" |
4987 | 4981 |
|
4988 | | - async_track_template(hass, Template("blah"), lambda x, y, z: None) |
4989 | | - assert message in caplog.text |
4990 | | - caplog.clear() |
| 4982 | + with pytest.raises(HomeAssistantError, match=message): |
| 4983 | + async_track_template(hass, Template("blah"), lambda x, y, z: None) |
4991 | 4984 |
|
4992 | 4985 | async_track_template(hass, Template("blah", hass), lambda x, y, z: None) |
4993 | | - assert message not in caplog.text |
4994 | | - caplog.clear() |
4995 | 4986 |
|
4996 | 4987 |
|
4997 | | -async def test_async_track_template_result_no_hass_deprecated( |
4998 | | - hass: HomeAssistant, caplog: pytest.LogCaptureFixture |
4999 | | -) -> None: |
5000 | | - """Test async_track_template_result with a template without hass is deprecated.""" |
5001 | | - message = ( |
5002 | | - "Detected code that calls async_track_template_result with template without " |
5003 | | - "hass. This will stop working in Home Assistant 2025.10, please " |
5004 | | - "report this issue" |
5005 | | - ) |
| 4988 | +async def test_async_track_template_result_no_hass_fails(hass: HomeAssistant) -> None: |
| 4989 | + """Test async_track_template_result with a template without hass now fails.""" |
| 4990 | + message = "Calls async_track_template_result with template without hass" |
5006 | 4991 |
|
5007 | | - async_track_template_result( |
5008 | | - hass, [TrackTemplate(Template("blah"), None)], lambda x, y, z: None |
5009 | | - ) |
5010 | | - assert message in caplog.text |
5011 | | - caplog.clear() |
| 4992 | + with pytest.raises(HomeAssistantError, match=message): |
| 4993 | + async_track_template_result( |
| 4994 | + hass, [TrackTemplate(Template("blah"), None)], lambda x, y, z: None |
| 4995 | + ) |
5012 | 4996 |
|
5013 | 4997 | async_track_template_result( |
5014 | 4998 | hass, [TrackTemplate(Template("blah", hass), None)], lambda x, y, z: None |
5015 | 4999 | ) |
5016 | | - assert message not in caplog.text |
5017 | | - caplog.clear() |
0 commit comments