{"id":24058,"library":"mockredispy","title":"mockredispy","description":"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.","status":"active","version":"2.9.3","language":"python","source_language":"en","source_url":"https://github.com/locationlabs/mockredis","tags":["testing","mock","redis","fixtures"],"install":[{"cmd":"pip install mockredispy","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"MockRedis inherits from redis-py's StrictRedis or Redis classes for compatibility","package":"redis","optional":false}],"imports":[{"note":"common outdated import path","wrong":"from mockredis.mock import MockRedis","symbol":"MockRedis","correct":"from mockredis import MockRedis"},{"note":"incorrect function name","wrong":"from mockredis import mock_redis","symbol":"mock_redis_client","correct":"from mockredis import mock_redis_client"}],"quickstart":{"code":"from mockredis import MockRedis\n\n# Create a mock Redis client\nr = MockRedis()\nr.set('key', 'value')\nprint(r.get('key'))  # b'value'","lang":"python","description":"Basic usage: create a MockRedis instance and use it like a real redis client."},"warnings":[{"fix":"Check the mockredis documentation for supported commands, or use fakeredis as an alternative.","message":"MockRedis does not support all Redis commands; scripts (LUA), pub/sub, and certain advanced features are not implemented.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use 'mock_redis_client' instead of 'mock_redis'.","message":"The method 'mock_redis' has been renamed to 'mock_redis_client' in newer versions.","severity":"deprecated","affected_versions":">=2.9.0"},{"fix":"Decode bytes to string using .decode() if needed: r.get('key').decode()","message":"MockRedis returns bytes for string values, similar to redis-py, but may cause confusion when comparing with expected strings.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'2.9.3':35 'code':19 'command':45 'connect':25 'current':32 'fixtur':52 'implement':11 'interact':21 'librari':6 'limit':48 'mock':10,50 'mockredispi':1,2 'period':37 'provid':8 'py':15,44 'python':5 'real':28 'redi':14,23,29,43,51 'redis-pi':13,42 'releas':38 'server':30 'support':40 'test':18,49 'use':16 'version':33 'without':24","created_at":"2026-05-01T08:11:03.964396+00:00","updated_at":"2026-05-01T08:11:03.964396+00:00","problems":[{"fix":"Run 'pip install mockredispy' and ensure the import is 'from mockredis import MockRedis'.","cause":"The library is not installed or import path is incorrect.","error":"ImportError: No module named mockredis"},{"fix":"Upgrade to the latest version: 'pip install --upgrade mockredispy'","cause":"The installed version may be outdated; older versions of mockredis did not support pipelines.","error":"AttributeError: 'MockRedis' object has no attribute 'pipeline'"},{"fix":"Use correct import: 'from mockredis import MockRedis' then call 'MockRedis()'","cause":"You tried to instantiate MockRedis incorrectly (e.g., MockRedis() but MockRedis is a module).","error":"TypeError: 'MockRedis' object is not callable"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.9.3","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/mockredispy/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}