mirror of
https://github.com/home-assistant/core.git
synced 2026-09-27 01:46:11 -04:00
Combine nested async with statements in timeout tests (#183026)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Paulus Schoutsen
Claude Opus 5
parent
0c38cadb7e
commit
b05f9ef587
+19
-15
@@ -122,13 +122,13 @@ async def test_mix_global_timeout_freeze_and_zone_freeze_other_zone_inside_execu
|
||||
with timeout.freeze("not_recorder"):
|
||||
time.sleep(0.3)
|
||||
|
||||
with pytest.raises(TimeoutError): # noqa: PT012
|
||||
async with timeout.async_timeout(0.1):
|
||||
async with (
|
||||
timeout.async_timeout(0.2, zone_name="recorder"),
|
||||
timeout.async_timeout(0.2, zone_name="not_recorder"),
|
||||
):
|
||||
await hass.async_add_executor_job(_some_sync_work)
|
||||
with pytest.raises(TimeoutError):
|
||||
async with (
|
||||
timeout.async_timeout(0.1),
|
||||
timeout.async_timeout(0.2, zone_name="recorder"),
|
||||
timeout.async_timeout(0.2, zone_name="not_recorder"),
|
||||
):
|
||||
await hass.async_add_executor_job(_some_sync_work)
|
||||
|
||||
|
||||
async def test_mix_global_timeout_freeze_and_zone_freeze_executor_2nd_outside_zone(
|
||||
@@ -304,20 +304,24 @@ async def test_multiple_zone_timeout() -> None:
|
||||
"""Test a simple zone timeout."""
|
||||
timeout = TimeoutManager()
|
||||
|
||||
with pytest.raises(TimeoutError): # noqa: PT012
|
||||
async with timeout.async_timeout(0.1, "test"):
|
||||
async with timeout.async_timeout(0.5, "test"):
|
||||
await asyncio.sleep(0.3)
|
||||
with pytest.raises(TimeoutError):
|
||||
async with (
|
||||
timeout.async_timeout(0.1, "test"),
|
||||
timeout.async_timeout(0.5, "test"),
|
||||
):
|
||||
await asyncio.sleep(0.3)
|
||||
|
||||
|
||||
async def test_different_zone_timeout() -> None:
|
||||
"""Test a simple zone timeout."""
|
||||
timeout = TimeoutManager()
|
||||
|
||||
with pytest.raises(TimeoutError): # noqa: PT012
|
||||
async with timeout.async_timeout(0.1, "test"):
|
||||
async with timeout.async_timeout(0.5, "other"):
|
||||
await asyncio.sleep(0.3)
|
||||
with pytest.raises(TimeoutError):
|
||||
async with (
|
||||
timeout.async_timeout(0.1, "test"),
|
||||
timeout.async_timeout(0.5, "other"),
|
||||
):
|
||||
await asyncio.sleep(0.3)
|
||||
|
||||
|
||||
async def test_simple_zone_timeout_freeze() -> None:
|
||||
|
||||
Reference in New Issue
Block a user