asynctest
Enhance the standard unittest package with features for testing asyncio libraries
What it is and what it does
asynctest is a testing library that builds on Python's standard unittest module to reduce boilerplate when writing tests for asyncio code. It provides CoroutineMock objects that properly mock coroutine functions, a TestCase subclass that automatically manages event loops for each test, and utilities to mock file and socket objects for selector-based testing. The library also includes helpers to control loop timing and run timed events without wall-clock delays.
The package is dormant—its last release was in 2019 and it has received no commits since 2024-04-22. It supports Python 3.5 and later but currently targets the selector event loop model and does not support Windows' proactor. You should verify whether asynctest still adds value for your use case before adopting.
Use it for:
- Mock coroutine functions in unit tests without manually wrapping them or managing their return values.
- Run async test methods and setUp/tearDown coroutines within a managed event loop per test.
- Control event loop timing in tests via ClockedTestCase to run timed callbacks without waiting for wall-clock time.
- Mock file and socket objects for testing selector-based I/O code without real network or filesystem calls.
- Patch async functions and generators with custom behavior using asynctest's patch decorators.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Extends Python's unittest module with test utilities and mocks designed specifically for testing asyncio-based libraries, including coroutine mocks and event loop management.
Yes, if you are testing asyncio code on Python 3.5 or later and need selector-specific mocking utilities. No, if you need active maintenance and bug fixes—the package is dormant and unlikely to receive updates. Verify that asynctest's feature set meets your needs before adopting.
Install
asynctest on PyPI
pip
pip install asynctestuv
uv add asynctestpoetry
poetry add asynctestInstalling asynctest
Before you install
Low install friction with no runtime dependencies. Maintenance is dormant—last release was 2019-05-14 and no commits since 2024-04-22—so expect no active bug fixes or feature updates.
License in practice
Licensed under Apache 2 (permissive), so you can use, modify, and distribute the package freely with minimal restrictions.
Quickstart
pip install asynctest
import asynctest
import unittest
class MyAsyncTest(asynctest.TestCase):
async def test_async_function(self):
mock = asynctest.CoroutineMock()
await mock()
mock.assert_called_once()
Requires Python 3.5 or later; targets the selector model and does not yet support Windows' proactor event loop.
Verify before relying
- Whether asynctest's selector-based approach remains compatible with modern Python asyncio implementations.
- Current community adoption and whether built-in async mock utilities have superseded asynctest's CoroutineMock for most use cases.
Package facts
| License | Apache 2 (permissive) |
| Python support | supports the current Python release (>=3.5) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 2,649 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 11,182,646/month — #1,411 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: asynctest-0.13.0-py3-none-any.whl
Keywords: unittest, test, testing, asyncio, tulip, selectors, async, mock
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
aiounittestProvides a test case class for writing unit…
permissive · top 15,000 on PyPI
asyncmockProvides awaitable mock objects for testing…
permissive · top 15,000 on PyPI
TestSlideTestSlide is a test framework for Python that…
permissive · top 15,000 on PyPI
aioresponsesMocks HTTP requests made by aiohttp's…
permissive · top 5,000 on PyPI
syncerSyncer converts async functions to synchronous…
permissive · top 15,000 on PyPI
blockbusterBlockbuster detects and prevents blocking calls…
permissive · top 5,000 on PyPI
flexmockflexmock creates mock, stub, spy, and fake…
permissive · top 15,000 on PyPI
nest-asyncioPatches asyncio to allow nested event loops,…
permissive · top 1,000 on PyPI
aiodebugaiodebug provides monitoring and testing…
permissive · top 15,000 on PyPI