--- id: pymongo-inmemory version: "0.5.0" license: MIT license_treatment: permissive maintenance: aging --- # pymongo_inmemory — A mongo mocking library with an ephemeral MongoDB running in memory. License: permissive · Maintenance: aging · Downloads: 117.4K/mo ## 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 above — verify before relying. Provides an in-memory MongoDB instance for testing by wrapping pymongo's MongoClient, eliminating the need for a running MongoDB server during development and test runs. 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 pip install pymongo-inmemory uv add pymongo-inmemory poetry add pymongo-inmemory ## Installing pymongo_inmemory 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). 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 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. 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_current - Install friction: low - Maintenance: aging - Downloads: 117.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags mongodb mocking for tests, in-memory mongo database, pymongo testing library, ephemeral mongodb instance, mongodb test fixture, mongo mock server, testing without mongodb server, mongodb-testing, test-fixtures, mocking [View on SkillFed](https://skillfed.io/packages/pymongo-inmemory) · [View on PyPI](https://pypi.org/project/pymongo-inmemory/)