asyncmock
Extension to the standard mock framework to support support async
What it is and what it does
Asyncmock extends the standard mock library to support testing async code by providing an AsyncMock class that behaves like a regular Mock but can be awaited. It handles async method calls, side effects, and return values, allowing developers to mock coroutines and async functions in unit tests.
The package was designed as a backport for Python versions before 3.8, when awaitable mocks were not yet part of the standard library. It is now superseded by built-in functionality—the description notes that Mock 4.0+ (included within Python 3.8+) now includes an awaitable mock mock.AsyncMock, which is recommended for new projects. The package is no longer maintained—its repository is archived and the last release was in 2020-03-15.
Use it for:
- Mock async functions in unit tests for Python 3.6–3.7 projects that predate built-in AsyncMock
- Test async methods with call assertions and side effects in older codebases
- Verify that async code correctly awaits mocked coroutines during development
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides awaitable mock objects for testing async code, extending the standard mock framework with AsyncMock that can be awaited like coroutines.
No, not for new projects. The description explicitly notes that Mock 4.0+ (included within Python 3.8+) now includes mock.AsyncMock and recommends it for new projects. For legacy Python 3.6–3.7 codebases, this package is an option, but its abandonment means no maintenance or compatibility updates.
Install
asyncmock on PyPI
pip
pip install asyncmockuv
uv add asyncmockpoetry
poetry add asyncmockInstalling asyncmock
Before you install
Low friction installation with a single runtime dependency (mock). However, the package is archived and abandoned since 2022-08-22, with no releases after 2020-03-15.
License in practice
BSD-3-Clause is permissive and imposes minimal restrictions on use or redistribution in your own projects.
Quickstart
pip install asyncmock
from asyncmock import AsyncMock
my_mock = AsyncMock()
await my_mock("foo", bar=123)
my_mock.assert_called_with("foo", bar=123)
Requires Python 3.6 or later; requires an async runtime context to execute the await statement.
Verify before relying
- Whether the package remains compatible with current Python versions despite abandonment since 2022
- How much of asyncmock's functionality overlaps with mock.AsyncMock available in Python 3.8+
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — mock |
| Maintenance | abandoned — 2,343 days since the last release |
| Last repo commit | (repository archived) |
| First released | |
| Downloads | 284,212/month — #8,065 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: asyncmock-0.4.2-py3-none-any.whl
Keywords: testing, mock, asyncio
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
mock-openProvides a drop-in replacement for…
permissive · top 15,000 on PyPI
flexmockflexmock creates mock, stub, spy, and fake…
permissive · top 15,000 on PyPI
calleeProvides argument matchers for unittest.mock…
permissive · top 15,000 on PyPI
looptimeLooptime fakes the passage of time in asyncio…
permissive · top 15,000 on PyPI
time-machineMocks and freezes time in tests, allowing you…
permissive · top 1,000 on PyPI
aresponsesMocks external HTTP/HTTPS services for…
permissive · top 15,000 on PyPI
asynctestExtends Python's unittest module with test…
permissive · top 5,000 on PyPI
mongomock-motorProvides an async mock client for MongoDB that…
permissive · top 5,000 on PyPI
pytest-mockProvides a pytest fixture that wraps the mock…
permissive · top 1,000 on PyPI