Skip to content

Instantly share code, notes, and snippets.

@pfertyk
pfertyk / test_response_status.py
Created June 21, 2017 21:46
Testing response status for aiohttp ClientSession
import random
from aiohttp import ClientSession
from asynctest import CoroutineMock, MagicMock, patch
async def get_random_photo_url():
while True:
async with ClientSession() as session:
async with session.get('random.photos') as resp:
json = await resp.json()