mirror of
https://github.com/home-assistant/core.git
synced 2026-05-08 17:49:37 +01:00
Improve error message for global timeout (#141563)
* Improve error message for global timeout * Add test * Message works with zone too
This commit is contained in:
@@ -36,6 +36,18 @@ async def test_simple_global_timeout_freeze() -> None:
|
||||
await asyncio.sleep(0.3)
|
||||
|
||||
|
||||
async def test_simple_global_timeout_cancel_message() -> None:
|
||||
"""Test a simple global timeout cancel message."""
|
||||
timeout = TimeoutManager()
|
||||
|
||||
with suppress(TimeoutError):
|
||||
async with timeout.async_timeout(0.1, cancel_message="Test"):
|
||||
with pytest.raises(
|
||||
asyncio.CancelledError, match="Global task timeout: Test"
|
||||
):
|
||||
await asyncio.sleep(0.3)
|
||||
|
||||
|
||||
async def test_simple_zone_timeout_freeze_inside_executor_job(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
@@ -222,6 +234,16 @@ async def test_simple_zone_timeout() -> None:
|
||||
await asyncio.sleep(0.3)
|
||||
|
||||
|
||||
async def test_simple_zone_timeout_cancel_message() -> None:
|
||||
"""Test a simple zone timeout cancel message."""
|
||||
timeout = TimeoutManager()
|
||||
|
||||
with suppress(TimeoutError):
|
||||
async with timeout.async_timeout(0.1, "test", cancel_message="Test"):
|
||||
with pytest.raises(asyncio.CancelledError, match="Zone timeout: Test"):
|
||||
await asyncio.sleep(0.3)
|
||||
|
||||
|
||||
async def test_simple_zone_timeout_does_not_leak_upward(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user