{"library":"pytest-redis","title":"pytest-redis","description":"pytest-redis is a pytest plugin that provides Redis fixtures and fixture factories, enabling developers to test code that relies on a running Redis database. It simplifies the setup and teardown of Redis instances for testing, offering fixtures for Redis processes and clients. The current version is 4.0.0 and it maintains an active release cadence, primarily updating to support newer Python and pytest versions.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install pytest-redis"],"cli":null},"imports":["def test_something(redisdb):","def test_something_with_proc(redis_proc):","def test_something_with_noproc(redis_noproc):","from pytest_redis import factories"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pytest\nfrom redis import Redis\nfrom pytest_redis import factories\nimport os\n\n# Basic test using the default function-scoped redisdb fixture\ndef test_can_connect(redisdb: Redis):\n    # Ensure environment variables for Redis connection (if needed by redis-py)\n    # are not hardcoded in actual tests, though pytest-redis manages the server.\n    # For direct Redis client instantiation, you might do:\n    # client = Redis(host=os.environ.get('REDIS_HOST', 'localhost'), \n    #                port=int(os.environ.get('REDIS_PORT', '6379')))\n\n    redisdb.set(\"ping\", \"pong\")\n    assert redisdb.get(\"ping\") == b\"pong\"\n    print(f\"Redis DB size: {redisdb.dbsize()}\")\n\n# Creating custom fixtures using factories\n# Example: A session-scoped Redis process with a specific port or configuration\ncustom_redis_proc = factories.redis_proc(port=6380)\n\n# A client fixture that uses the custom process\n# Note: The string 'custom_redis_proc' matches the variable name of the proc fixture\ncustom_redis_client = factories.redisdb('custom_redis_proc')\n\n# Test using the custom client fixture\ndef test_custom_redis_instance(custom_redis_client: Redis):\n    custom_redis_client.set(\"mykey\", \"myvalue\")\n    assert custom_redis_client.get(\"mykey\") == b\"myvalue\"\n    assert custom_redis_client.info()['tcp_port'] == 6380","lang":"python","description":"This quickstart demonstrates how to use the built-in `redisdb` fixture for basic Redis operations within a test. It also illustrates how to create and use custom, named Redis process and client fixtures using `pytest_redis.factories` to allow for specific configurations (like a custom port) or different scopes. Run with `pytest` after installing `pytest-redis` and `redis` client.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"3.1.3","pypi_latest":"4.0.0","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":3.4,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pytest-redis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"35.7M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pytest-redis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":3.5,"import_time_s":null,"mem_mb":null,"disk_size":"36M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pytest-redis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"39.6M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pytest-redis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":3.2,"import_time_s":null,"mem_mb":null,"disk_size":"40M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pytest-redis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"31.0M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pytest-redis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":3.1,"import_time_s":null,"mem_mb":null,"disk_size":"32M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pytest-redis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"30.7M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pytest-redis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":3.1,"import_time_s":null,"mem_mb":null,"disk_size":"31M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pytest-redis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"34.5M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pytest-redis","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":3.9,"import_time_s":null,"mem_mb":null,"disk_size":"35M"}]}}