From 5ae366957f1b4f4199fb284c24b4fce839d593e6 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 23 Aug 2023 10:52:19 +0200 Subject: [PATCH] Fix imap test RuntimeWarning (#98865) --- tests/components/imap/test_init.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/components/imap/test_init.py b/tests/components/imap/test_init.py index b9512da0278..b4ee11ba787 100644 --- a/tests/components/imap/test_init.py +++ b/tests/components/imap/test_init.py @@ -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