async-mock-call-without-await-assertion
Pair positive AsyncMock call assertions with evidence that the mock was awaited.
Why
Calling an AsyncMock records a call before its coroutine is awaited. A positive call assertion can therefore pass when production code silently drops the coroutine. Await assertions cover that gap, while call assertions still detect extra calls whose coroutines were never awaited.
Fix
Keep the call assertion and add an appropriate assert_awaited assertion. For a test that deliberately checks scheduling before execution, use an exact SARJ456 suppression explaining that contract.
Examples
from unittest.mock import AsyncMock
async def test_delivery(): send = AsyncMock() await deliver(send) send.assert_called_once_with("item")from unittest.mock import AsyncMock
async def test_delivery(): send = AsyncMock() await deliver(send) send.assert_called_once_with("item") send.assert_awaited_once_with("item")from unittest.mock import AsyncMock
async def test_delivery(): send = AsyncMock() await deliver(send) assert send.call_count == 1 assert send.await_count >= 0from unittest.mock import AsyncMock
async def test_delivery(expected): send = AsyncMock() await deliver(send) send.assert_called_once() send.assert_has_awaits(expected)from unittest.mock import AsyncMock
async def test_delivery(): send = AsyncMock() await deliver(send) send.assert_called_once() assert len(send.await_args_list) >= 0from unittest.mock import AsyncMock
async def test_delivery(): send = AsyncMock() await deliver(send) send.assert_called_once() assert len(send.await_args_list) == 1from unittest.mock import AsyncMock
async def test_delivery(): send = AsyncMock() pending = send() pending.close() assert send.calledfrom unittest.mock import AsyncMock
async def test_delivery(): send = AsyncMock() await send() assert send.called send.assert_awaited_once()