mongomock-motor
Library for mocking AsyncIOMotorClient built on top of mongomock.
What it is and what it does
mongomock-motor wraps the mongomock library to provide an async-compatible mock of MongoDB's AsyncIOMotorClient. It lets you write and test async MongoDB code without spinning up a real database server, using the same async/await patterns you'd use with the actual motor library. The mock implements the core AsyncIOMotorClient, Database, and Collection interfaces, returning coroutines that can be awaited in your test code.
The package is built on top of mongomock, which handles the in-memory database simulation, and motor, which defines the async API contract. It's intended for unit and integration testing of applications that use motor for async MongoDB access. Since it's a pure-Python implementation with no external database dependency, it's fast and lightweight for test environments.
Use it for:
- Unit test async MongoDB code without requiring a test MongoDB instance or Docker container.
- Mock motor client in CI/CD pipelines where spinning up a database would slow down test runs.
- Develop and test async MongoDB queries locally without database setup overhead.
- Verify async query logic and collection operations in isolation before integration testing.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides an async mock client for MongoDB that mimics the AsyncIOMotorClient API, allowing you to test async MongoDB code without a running database.
Yes, if you write async MongoDB code with motor and want to test without a real database. The low install friction, permissive license, and current Python version support make it a straightforward addition to a test suite. The aging maintenance status (455 days since last release) is a minor concern for a stable mock library, but the lack of security vulnerabilities and active repository suggest it remains usable. Verify that the mock covers the specific motor APIs your code relies on before committing to it.
Install
mongomock-motor on PyPI
pip
pip install mongomock-motoruv
uv add mongomock-motorpoetry
poetry add mongomock-motorInstalling mongomock-motor
Before you install
Low install friction with a pure-Python wheel. Maintenance status is aging—last release was 455 days ago—but the repository is not archived and the package supports current Python versions through 3.13.
License in practice
MIT license is permissive; you can use this package freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install mongomock-motor
from mongomock_motor import AsyncMongoMockClient
async def test():
collection = AsyncMongoMockClient()['db']['collection']
await collection.insert_one({'a': 1})
docs = await collection.find({}).to_list(None)
return docs
Requires Python 3.8 or later; async/await syntax required in calling code.
Verify before relying
- Completeness of AsyncIOMotorClient API coverage—which methods and features are fully mocked vs. stubbed or missing.
- Performance characteristics and suitability for large test datasets or high-volume mock operations.
- Known limitations or edge cases where mock behavior diverges from actual Motor/MongoDB behavior.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — mongomock, motor |
| Maintenance | aging — 455 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,467,915/month — #3,873 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mongomock_motor-0.0.36-py3-none-any.whl
Keywords: library, mongodb
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
mongomockMongomock provides an in-memory mock of MongoDB…
permissive · top 5,000 on PyPI
motorMotor provides a non-blocking MongoDB driver…
permissive · top 5,000 on PyPI
motor-typesProvides Python type stubs for Motor, enabling…
permissive · top 15,000 on PyPI
django-mock-queriesMocks Django QuerySet operations in memory for…
permissive · top 15,000 on PyPI
asyncmockProvides awaitable mock objects for testing…
permissive · top 15,000 on PyPI
odmanticODMantic is an async-first Object Document…
permissive · top 15,000 on PyPI
pymongo_inmemoryProvides an in-memory MongoDB instance for…
permissive · top 15,000 on PyPI
Flask-PyMongoFlask-PyMongo integrates MongoDB database…
permissive · top 15,000 on PyPI
moto-extMocks AWS services for testing by intercepting…
permissive · top 15,000 on PyPI
aioresponsesMocks HTTP requests made by aiohttp's…
permissive · top 5,000 on PyPI