skillfed

asynctest

Enhance the standard unittest package with features for testing asyncio libraries

asynctest v0.13.0 11.2M downloads/30d#1,411 on PyPI310
Permissive license Apache 2 DORMANT released

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 asynctest

uv

uv add asynctest

poetry

poetry add asynctest

Installing 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

Development Status :: 3 - AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Testing

Tags

asyncio unit testingasync mock testingcoroutine mockasyncio test utilitiesasync unittest frameworkevent loop testingasyncio test case
asyncio-testingmock-utilities

More Testing packages