mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Add more debug details to running timeouts (#43644)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
@@ -266,3 +266,60 @@ async def test_mix_zone_timeout_trigger_global_cool_down():
|
||||
pass
|
||||
|
||||
await asyncio.sleep(0.2)
|
||||
|
||||
|
||||
async def test_simple_zone_timeout_freeze_without_timeout_cleanup(hass):
|
||||
"""Test a simple zone timeout freeze on a zone that does not have a timeout set."""
|
||||
timeout = TimeoutManager()
|
||||
|
||||
async def background():
|
||||
async with timeout.async_freeze("test"):
|
||||
await asyncio.sleep(0.4)
|
||||
|
||||
async with timeout.async_timeout(0.1):
|
||||
hass.async_create_task(background())
|
||||
await asyncio.sleep(0.2)
|
||||
|
||||
|
||||
async def test_simple_zone_timeout_freeze_without_timeout_cleanup2(hass):
|
||||
"""Test a simple zone timeout freeze on a zone that does not have a timeout set."""
|
||||
timeout = TimeoutManager()
|
||||
|
||||
async def background():
|
||||
async with timeout.async_freeze("test"):
|
||||
await asyncio.sleep(0.2)
|
||||
|
||||
with pytest.raises(asyncio.TimeoutError):
|
||||
async with timeout.async_timeout(0.1):
|
||||
hass.async_create_task(background())
|
||||
await asyncio.sleep(0.3)
|
||||
|
||||
|
||||
async def test_simple_zone_timeout_freeze_without_timeout_exeption():
|
||||
"""Test a simple zone timeout freeze on a zone that does not have a timeout set."""
|
||||
timeout = TimeoutManager()
|
||||
|
||||
with pytest.raises(asyncio.TimeoutError):
|
||||
async with timeout.async_timeout(0.1):
|
||||
try:
|
||||
async with timeout.async_freeze("test"):
|
||||
raise RuntimeError()
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
await asyncio.sleep(0.4)
|
||||
|
||||
|
||||
async def test_simple_zone_timeout_zone_with_timeout_exeption():
|
||||
"""Test a simple zone timeout freeze on a zone that does not have a timeout set."""
|
||||
timeout = TimeoutManager()
|
||||
|
||||
with pytest.raises(asyncio.TimeoutError):
|
||||
async with timeout.async_timeout(0.1):
|
||||
try:
|
||||
async with timeout.async_timeout(0.3, "test"):
|
||||
raise RuntimeError()
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
await asyncio.sleep(0.3)
|
||||
|
||||
Reference in New Issue
Block a user