--- id: asynctest version: "0.13.0" license: Apache 2 license_treatment: permissive maintenance: dormant --- # asynctest — Enhance the standard unittest package with features for testing asyncio libraries License: permissive · Maintenance: dormant · Downloads: 11.2M/mo ## 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 above — 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 pip install asynctest uv add asynctest 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_current - Install friction: low - Maintenance: dormant - Downloads: 11.2M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags asyncio unit testing, async mock testing, coroutine mock, asyncio test utilities, async unittest framework, event loop testing, asyncio test case, asyncio-testing, mock-utilities [View on SkillFed](https://skillfed.io/packages/asynctest) · [View on PyPI](https://pypi.org/project/asynctest/)