Testing aiohttp client with unittest.mock.patch
问题 I've written a simple HTTP client using aiohttp and I'm trying to test it by patching aiohttp.ClientSession and aiohttp.ClientResponse . However, it appears as though the unittest.mock.patch decorator is not respecting my asynchronous code. At a guess, I would say it's some kind of namespacing mismatch. Here's a minimal example: from aiohttp import ClientSession async def is_ok(url:str) -> bool: async with ClientSession() as session: async with session.request("GET", url) as response: return