Registry / testing / pytest-mongo

pytest-mongo

JSON →
library4.0.0pypypiunverified

MongoDB process and client fixtures plugin for Pytest. Provides fixtures to start a MongoDB process and provide a pymongo client. Version 4.0.0 requires Python >=3.10 and uses the pytest-dbfixtures framework for managing MongoDB processes.

pip install pytest-mongo
INSTALL
IMPORT
SIG · PYTEST-MONGO
P
pytest-mongo
testingpythonv4.0.0
Install
4.1s avg
Import
Disk
40MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 40MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.1s · import 0.000s · 42MB
40MB installed
● package 40MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mongo_proc
from pytest_mongo import mongo_proc
from pytest_mongo import mongo_proc

Add pytest_plugins to conftest or test file, then use mongo_client fixture directly.

import pytest pytest_plugins = ["pytest_mongo"] def test_mongo(mongo_client): db = mongo_client.test_database collection = db.test_collection collection.insert_one({"name": "test"}) assert collection.find_one({"name": "test"}) is not None
Debug
Known issues
breakingpytest-mongo 4.0.0 drops support for Python <3.10 and may change fixture scopes. Ensure Python >=3.10 and review fixture scope parameters.
fix
Upgrade Python to 3.10+ and adjust conftest.py fixture scopes if relying on session-scoped defaults.
affects: >=4.0.0
gotchaThe mongo_proc fixture starts a real MongoDB process. It downloads mongod if not found, which can be slow and may fail on restricted CI environments.
fix
Set the MONGODB_BINARY environment variable to an existing mongod binary to skip download. Or use a pre-installed MongoDB in CI.
affects: all
deprecatedDirect use of 'mongo_process' or 'mongod' fixtures from old pytest-mongo-dbfixtures is deprecated. Use mongo_proc and mongo_client from pytest_mongo.
fix
Replace pytest-mongo-dbfixtures with pytest-mongo and use mongo_proc and mongo_client.
affects: >=3.0.0
Upgrade
Version history
4.0.0latest on PyPI · released Feb 4, 2026
Audit
Dependencies
pytest-dbfixturesrequiredCore dependency providing MongoDB process management.
pymongorequiredClient fixture uses pymongo.MongoClient.
Agent activity
12 hits · last 30 days
node
10
Resources
pytest-mongo — pip install pytest-mongo · libregistry