Patch the async json response of a mocked aiohttp clientsession in pytest

Haven&rsquo;t found a short concise example covering pytest whilst focussing the patched json method of a mocked async session, hence this snippet. First install pytest-asyncio . pipenv install -d pytest-asyncio Now use it as highlighted. from unittest.mock import patch, AsyncMock import aiohttp import pytest async def request_async (): async with aiohttp . ClientSession(headers = {}) as session:…