mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 00:07:10 +00:00
Fix imap test RuntimeWarning (#98865)
This commit is contained in:
parent
6be47b1fbd
commit
5ae366957f
@ -470,6 +470,8 @@ async def test_reset_last_message(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Test receiving a message successfully."""
|
"""Test receiving a message successfully."""
|
||||||
event = asyncio.Event() # needed for pushed coordinator to make a new loop
|
event = asyncio.Event() # needed for pushed coordinator to make a new loop
|
||||||
|
idle_start_future = asyncio.Future()
|
||||||
|
idle_start_future.set_result(None)
|
||||||
|
|
||||||
async def _sleep_till_event() -> None:
|
async def _sleep_till_event() -> None:
|
||||||
"""Simulate imap server waiting for pushes message and keep the push loop going.
|
"""Simulate imap server waiting for pushes message and keep the push loop going.
|
||||||
@ -479,10 +481,10 @@ async def test_reset_last_message(
|
|||||||
nonlocal event
|
nonlocal event
|
||||||
await event.wait()
|
await event.wait()
|
||||||
event.clear()
|
event.clear()
|
||||||
mock_imap_protocol.idle_start.return_value = AsyncMock()()
|
mock_imap_protocol.idle_start = AsyncMock(return_value=idle_start_future)
|
||||||
|
|
||||||
# Make sure we make another cycle (needed for pushed coordinator)
|
# Make sure we make another cycle (needed for pushed coordinator)
|
||||||
mock_imap_protocol.idle_start.return_value = AsyncMock()()
|
mock_imap_protocol.idle_start = AsyncMock(return_value=idle_start_future)
|
||||||
# Mock we wait till we push an update (needed for pushed coordinator)
|
# Mock we wait till we push an update (needed for pushed coordinator)
|
||||||
mock_imap_protocol.wait_server_push.side_effect = _sleep_till_event
|
mock_imap_protocol.wait_server_push.side_effect = _sleep_till_event
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user