skillfed

asyncmock

Extension to the standard mock framework to support support async

asyncmock v0.4.2 284.2K downloads/30d#8,065 on PyPI8
Permissive license BSD-3-Clause Abandoned released

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 asyncmock

uv

uv add asyncmock

poetry

poetry add asyncmock

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

async mock testingmock async functionsasyncio test mockingawaitable mock objectsasync unit testingcoroutine mockingasync pytest mocking
testinglegacyabandoned

More Testing packages