async def testIterable(self): content_list = [ b'xyz', b'123', ] async def fake_iterator(self): for content in content_list: yield encrypt(content) mock = AsyncMock() mock.__aiter__ = fake_iterator async with DecryptReadableFile(mock) as fin: chunk_list = [chunk async for chunk in fin] self.assertEqual(chunk_list, content_list)