pymongo_inmemory
A mongo mocking library with an ephemeral MongoDB running in memory.
Decision gist · record as of 2026-08-14
Yes, if you test code that uses MongoDB and want to avoid external service dependencies. The low install friction, permissive license, and straightforward API make it a practical choice for unit and integration testing. The aging maintenance status (last release 519 days ago) is a minor concern but not a blocker—the repository is not archived and recent commits exist. No known security vulnerabilities.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later.
- The package downloads and runs a MongoDB binary, so adequate disk space and network access during first run are needed.
- Low friction install with a single runtime dependency (pymongo).
License · maintenance · safety
MIT (permissive) — MIT license is permissive, allowing use in commercial and private projects with minimal restrictions—only requiring attribution and inclusion of the license text.
last release 2025-03-13 (519 days) · last repo commit 2025-03-13 · 53 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 117,381 downloads/mo, #12,165 on PyPI
Alternatives
Verify before relying
pip install pymongo-inmemory
from pymongo_inmemory import MongoClient
with MongoClient() as client:
db = client['testdb']
collection = db['test-collection']
# use collection as normal- Whether the package successfully handles all MongoDB versions listed in its URL bank or if some versions have known issues.
- Performance characteristics and memory overhead of the in-memory MongoDB instance for large test datasets.
- Compatibility with all pymongo features or limitations in what MongoClient operations are supported.
What it is and what it does
pymongo_inmemory is a testing library that spins up an ephemeral MongoDB instance in memory, allowing you to test code that uses MongoDB without needing a separate MongoDB server running. It wraps pymongo's MongoClient and automatically handles downloading, extracting, and configuring a MongoDB binary for your OS and Python version. The instance runs only for the duration of your test and leaves no persistent state.
You configure it via setup.cfg or environment variables (setting things like MongoDB version, port, and data folder), then import MongoClient from pymongo_inmemory instead of pymongo. The API is identical to the standard pymongo client, so existing test code requires minimal changes. It caches downloaded MongoDB binaries to avoid repeated downloads, and supports MongoDB versions from 3.0 through 8.0 across Linux, macOS, and Windows.
Use it for
- Unit testing code that reads/writes to MongoDB without needing a test database server running locally or in CI.
- Integration testing a multi-service application where MongoDB is one component, using an isolated in-memory instance per test.
- Rapid development iteration on MongoDB queries and schema changes without managing a persistent test database.
- CI/CD pipelines where spinning up a full MongoDB container is too heavy or slow; the in-memory instance starts faster.
- Testing edge cases and error conditions by configuring specific MongoDB versions or configurations via environment variables.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you test code that uses MongoDB and want to avoid external service dependencies.
The low install friction, permissive license, and straightforward API make it a practical choice for unit and integration testing. The aging maintenance status (last release 519 days ago) is a minor concern but not a blocker—the repository is not archived and recent commits exist. No known security vulnerabilities.
Install
pymongo-inmemory on PyPI
Before you install
Low friction install with a single runtime dependency (pymongo). Maintenance status is aging—last release was 519 days ago, though the repository remains active with recent commits and no archived status. Supports current Python versions (3.9 through 3.13).
Requires Python 3.9 or later. The package downloads and runs a MongoDB binary, so adequate disk space and network access during first run are needed.
License in practice
MIT license is permissive, allowing use in commercial and private projects with minimal restrictions—only requiring attribution and inclusion of the license text.
Quickstart
pip install pymongo-inmemory
from pymongo_inmemory import MongoClient
with MongoClient() as client:
db = client['testdb']
collection = db['test-collection']
# use collection as normal
Verify before relying
- Whether the package successfully handles all MongoDB versions listed in its URL bank or if some versions have known issues.
- Performance characteristics and memory overhead of the in-memory MongoDB instance for large test datasets.
- Compatibility with all pymongo features or limitations in what MongoClient operations are supported.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release <4.0,>=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagepymongo |
| Maintenance | Aging 519 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 117,381 / month, #12,165 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 3 - AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.7Programming Language :: Python :: 3.9Topic :: Database :: Database Engines/ServersTopic :: Software Development :: TestingTopic :: Utilities |
Evidence: pymongo_inmemory-0.5.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “mongodb mocking for tests”
- pymongo_inmemoryProvides an in-memory MongoDB instance for testing by wrapping…
- pytest-mock-resourcesProvides pytest fixtures that spin up real database and service…
- mongomockMongomock provides an in-memory mock of MongoDB collections for…
Give your agent the search over MCP, or paste the wish link into any chat.
More Utilities packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also pymongo · mongomock · Flask-PyMongo · pymongoarrow · pymongocrypt · pymongo-auth-aws · motor · pydantic-mongo · gdbmongo · pymongoexplain