Registry / testing / openmock

openmock

JSON →
library3.2.0pypypi✓ verified 87d ago

A Python library for mocking OpenSearch (Elasticsearch) operations in unit tests. Provides a lightweight in-memory mock that simulates OpenSearch behaviors without needing a real cluster. Current version: 3.2.0, requires Python >=3.10. Release cadence irregular.

pip install openmock
INSTALL
IMPORT
SIG · OPENMOCK
O
openmock
testingpythonv3.2.0
Install
5.9s avg
Import
—
Disk
53MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v3.2.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.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 58.4MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 5.9s · import 0.000s · 58MB
53MB installed
● package 53MB
Code
Verified usage

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

FakeOpenSearch
✓ from openmock import FakeOpenSearch
✗ from openmock import OpenMock
FakeAsyncOpenSearch
✓ from openmock import AsyncFakeOpenSearch
✗ from openmock import OpenMock
patch
✓ from openmock import patch
✗ from openmock import OpenMock

Basic usage: use OpenMock as a context manager to mock OpenSearch client calls.

from openmock import OpenMock from opensearchpy import OpenSearch with OpenMock(): client = OpenSearch() # index a document client.index(index='my-index', body={'title': 'Test'}) # search result = client.search(index='my-index', body={'query': {'match_all': {}}}) print(result['hits']['hits'][0]['_source']['title']) # Output: Test
Debug
Known issues
breakingVersion 3.x dropped support for Python <3.10 and changed the import from 'openmock' (previously 'openmock.OpenMock' was sometimes imported incorrectly). Ensure your tests run on Python >=3.10.
fix
Upgrade Python to >=3.10 and use 'from openmock import OpenMock'.
affects: >=3.0.0
gotchaOpenMock does not persist state between different with-blocks or across separate test cases. Each context manager starts with a fresh mock cluster.
fix
Place all related OpenSearch operations within a single with block, or use the decorator form '@OpenMock()' for a whole test function.
affects: all
gotchaThe mock only supports a subset of OpenSearch APIs. Advanced features like snapshot/restore, scroll, or compatibility with specific OpenSearch plugins may not be available.
fix
Check the openmock documentation for the list of supported APIs. For unsupported operations, consider mocking manually or using a real test cluster.
affects: all
Upgrade
Version history
3.2.0latest on PyPI · released Apr 21, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Anthropic
1
Resources
openmock — pip install openmock · libregistry