Install & Compatibility
Where this runs
tested against v2.9.3 · 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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.020s · 19.5MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.9s · import 0.018s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
MockRedis
✓ from mockredis import MockRedis
✗ from mockredis.mock import MockRedis
common outdated import path
mock_redis_client
✓ from mockredis import mock_redis_client
✗ from mockredis import mock_redis
incorrect function name
Basic usage: create a MockRedis instance and use it like a real redis client.
from mockredis import MockRedis
# Create a mock Redis client
r = MockRedis()
r.set('key', 'value')
print(r.get('key')) # b'value'
Errors
Common errors & fixes
ImportError: No module named mockredis
The library is not installed or import path is incorrect.
fixRun 'pip install mockredispy' and ensure the import is 'from mockredis import MockRedis'.
AttributeError: 'MockRedis' object has no attribute 'pipeline'
The installed version may be outdated; older versions of mockredis did not support pipelines.
fixUpgrade to the latest version: 'pip install --upgrade mockredispy'
TypeError: 'MockRedis' object is not callable
You tried to instantiate MockRedis incorrectly (e.g., MockRedis() but MockRedis is a module).
fixUse correct import: 'from mockredis import MockRedis' then call 'MockRedis()'
Upgrade
Version history
2.9.3latest on PyPI · released Apr 18, 2016
Audit
Dependencies
redisrequiredMockRedis inherits from redis-py's StrictRedis or Redis classes for compatibility