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