mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Cleanup runtime warnings in async unit tests (#137308)
This commit is contained in:
parent
650351a7f3
commit
09cea6ce96
@ -134,8 +134,10 @@ async def test_create_eager_task_312(hass: HomeAssistant) -> None:
|
||||
async def test_create_eager_task_from_thread(hass: HomeAssistant) -> None:
|
||||
"""Test we report trying to create an eager task from a thread."""
|
||||
|
||||
coro = asyncio.sleep(0)
|
||||
|
||||
def create_task():
|
||||
hasync.create_eager_task(asyncio.sleep(0))
|
||||
hasync.create_eager_task(coro)
|
||||
|
||||
with pytest.raises(
|
||||
RuntimeError,
|
||||
@ -145,14 +147,19 @@ async def test_create_eager_task_from_thread(hass: HomeAssistant) -> None:
|
||||
):
|
||||
await hass.async_add_executor_job(create_task)
|
||||
|
||||
# Avoid `RuntimeWarning: coroutine 'sleep' was never awaited`
|
||||
await coro
|
||||
|
||||
|
||||
async def test_create_eager_task_from_thread_in_integration(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test we report trying to create an eager task from a thread."""
|
||||
|
||||
coro = asyncio.sleep(0)
|
||||
|
||||
def create_task():
|
||||
hasync.create_eager_task(asyncio.sleep(0))
|
||||
hasync.create_eager_task(coro)
|
||||
|
||||
frames = extract_stack_to_frame(
|
||||
[
|
||||
@ -200,6 +207,9 @@ async def test_create_eager_task_from_thread_in_integration(
|
||||
"self.light.is_on"
|
||||
) in caplog.text
|
||||
|
||||
# Avoid `RuntimeWarning: coroutine 'sleep' was never awaited`
|
||||
await coro
|
||||
|
||||
|
||||
async def test_get_scheduled_timer_handles(hass: HomeAssistant) -> None:
|
||||
"""Test get_scheduled_timer_handles returns all scheduled timer handles."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user