Registry / testing / mockredispy

mockredispy

JSON →
library2.9.3pypypi✓ verified 85d ago

mockredispy is a Python library that provides a mock implementation of redis-py, useful for testing code that interacts with Redis without connecting to a real Redis server. The current version is 2.9.3, with periodic releases. It supports most redis-py commands but has limitations.

pip install mockredispy
INSTALL
IMPORT
SIG · MOCKREDISPY
M
mockredispy
testingpythonv2.9.3
Install
2.9s avg
Import
19ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.020s · 19.5MB
glibc
py 3.103.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'
Debug
Known issues
gotchaMockRedis does not support all Redis commands; scripts (LUA), pub/sub, and certain advanced features are not implemented.
fix
Check the mockredis documentation for supported commands, or use fakeredis as an alternative.
affects: >=2.0.0
deprecatedThe method 'mock_redis' has been renamed to 'mock_redis_client' in newer versions.
fix
Use 'mock_redis_client' instead of 'mock_redis'.
affects: >=2.9.0
gotchaMockRedis returns bytes for string values, similar to redis-py, but may cause confusion when comparing with expected strings.
fix
Decode bytes to string using .decode() if needed: r.get('key').decode()
affects: all
Errors
Common errors & fixes
ImportError: No module named mockredis
The library is not installed or import path is incorrect.
fix
Run '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.
fix
Upgrade 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).
fix
Use 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
Agent activity
2 hits · last 30 days
node
2
Resources
mockredispy — pip install mockredispy · libregistry