Fix imap test RuntimeWarning (#98865)

This commit is contained in:
Marc Mueller 2023-08-23 10:52:19 +02:00 committed by GitHub
parent 6be47b1fbd
commit 5ae366957f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -470,6 +470,8 @@ async def test_reset_last_message(
) -> None:
"""Test receiving a message successfully."""
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:
"""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
await event.wait()
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)
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_imap_protocol.wait_server_push.side_effect = _sleep_till_event