{"library":"mongomock-motor","title":"mongomock-motor","description":"mongomock-motor is a Python library that provides a best-effort mock for the AsyncIOMotorClient, built on top of the `mongomock` library. It enables developers to test asynchronous MongoDB applications that use `motor` without requiring a running MongoDB instance. The library is currently active, with frequent patch and minor feature releases.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install mongomock-motor"],"cli":null},"imports":["from mongomock_motor import AsyncMongoMockClient","from motor.motor_asyncio import AsyncIOMotorClient"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import asyncio\nfrom mongomock_motor import AsyncMongoMockClient\n\nasync def main():\n    client = AsyncMongoMockClient() # Create a mock client\n    db = client['mydatabase']\n    collection = db['mycollection']\n\n    # Insert a document\n    insert_result = await collection.insert_one({\"name\": \"Test Document\", \"value\": 123})\n    print(f\"Inserted document with ID: {insert_result.inserted_id}\")\n\n    # Find a document\n    found_doc = await collection.find_one({\"name\": \"Test Document\"})\n    print(f\"Found document: {found_doc}\")\n    assert found_doc['value'] == 123\n\n    # Update a document\n    update_result = await collection.update_one(\n        {\"name\": \"Test Document\"},\n        {\"$set\": {\"value\": 456}}\n    )\n    print(f\"Modified {update_result.modified_count} document(s).\")\n    updated_doc = await collection.find_one({\"name\": \"Test Document\"})\n    print(f\"Updated document: {updated_doc}\")\n    assert updated_doc['value'] == 456\n    \n    # Close the mock client (good practice, though not strictly necessary for mock)\n    await client.close()\n\nif __name__ == '__main__':\n    asyncio.run(main())","lang":"python","description":"This quickstart demonstrates how to initialize `AsyncMongoMockClient` and perform basic asynchronous MongoDB operations (insert, find, update) against it, mimicking the API of `motor.motor_asyncio.AsyncIOMotorClient`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":"0.0.36","pypi_latest":"0.0.36","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":3,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"mongomock-motor","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"30.7M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"mongomock-motor","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":3.1,"import_time_s":null,"mem_mb":null,"disk_size":"33M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"mongomock-motor","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"34.3M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"mongomock-motor","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.9,"import_time_s":null,"mem_mb":null,"disk_size":"37M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"mongomock-motor","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"25.9M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"mongomock-motor","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.6,"import_time_s":null,"mem_mb":null,"disk_size":"30M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"mongomock-motor","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"25.6M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"mongomock-motor","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.7,"import_time_s":null,"mem_mb":null,"disk_size":"30M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"mongomock-motor","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"30.0M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"mongomock-motor","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":3.6,"import_time_s":null,"mem_mb":null,"disk_size":"31M"}]}}