Supports writing tests for code using the redis-py library without requiring a redis-server install.
Use pip:
pip install mockredispy
Both mockredis.mock_redis_client
and mockredis.mock_strict_redis_client
can be
used to patch instances of the redis client.
For example, using the mock library:
@patch('redis.Redis', mock_redis_client)
Or:
@patch('redis.StrictRedis', mock_strict_redis_client)
Many unit tests exist to verify correctness of mock functionality. In addition, most
unit tests support testing against an actual redis-server instance to verify the tests
against ground truth. See mockredis.tests.fixtures
for more details and disclaimers.
This code is shamelessly derived from work by John DeRosa.