1
0
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:
Pascal Vizeli
2021-01-04 13:10:39 +01:00
committed by GitHub
parent 5b67030c26
commit a7a4875f52
3 changed files with 70 additions and 6 deletions

View File

@@ -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)