Skip to content
Test python asyncio-based code with ease.
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
aiounittest mock file Jun 11, 2019
docs version up Jun 11, 2019
tests fix import Jun 11, 2019
.gitignore Initial commit Aug 16, 2017
.travis.yml Update .travis.yml Oct 10, 2018
LICENSE AsyncMockIterator Jun 11, 2019 include license Aug 17, 2017
README.rst 3.4 compat Jun 11, 2019 3.4 compat Jun 11, 2019



image0 image1


This is a helper library to ease of your pain (and boilerplate), when writing a test of the asynchronous code (asyncio). You can test:

  • synchronous code (same as the unittest.TestCase)
  • asynchronous code, it supports syntax with async/await (Python 3.5+) and asyncio.coroutine/yield from (Python 3.4)


Use pip:

pip install aiounittest


It's as simple as use of unittest.TestCase. Full docs at

import asyncio
import aiounittest

async def add(x, y):
    await asyncio.sleep(0.1)
    return x + y

class MyTest(aiounittest.AsyncTestCase):

    async def test_async_add(self):
        ret = await add(5, 6)
        self.assertEqual(ret, 11)

    # or 3.4 way
    def test_sleep(self):
        ret = yield from add(5, 6)
        self.assertEqual(ret, 11)

    # some regular test code
    def test_something(self):

Library provide some additional tooling:



You can’t perform that action at this time.