pytest-redis
Redis fixtures and fixture factories for Pytest.
What it is and what it does
pytest-redis is a pytest plugin that automates Redis setup and teardown for test suites. It provides three fixtures: redisdb (function-scoped client that cleans databases after each test), redis_proc (session-scoped process that starts Redis on first use and stops at test end), and redis_noproc (connects to an already-running Redis instance). The plugin manages port allocation, process lifecycle, and client connections, allowing developers to write tests that interact with Redis without manual server management.
The plugin integrates with pytest's fixture system and supports extensive configuration through fixture factory arguments, command-line options, or pytest.ini settings. It handles Redis executable discovery, port binding, authentication, logging, and data persistence options. Developers can create multiple Redis fixtures with different configurations for testing scenarios requiring multiple Redis instances or specific server settings.
Use it for:
- Unit testing code that reads/writes to Redis without requiring manual server startup or teardown between tests.
- Integration testing multi-instance Redis scenarios by creating separate redis_proc and redisdb fixtures with different configurations.
- Testing against an external Redis instance in CI/CD by using redis_noproc fixture to connect to a pre-running container.
- Validating Redis-based caching layers and session stores in web applications during test execution.
- Testing Redis Pub/Sub or stream functionality by configuring multiple client fixtures against a single Redis process.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that provides fixtures for testing code that depends on Redis, managing both Redis process lifecycle and client connections during test execution.
Yes. The plugin is actively maintained, has low install friction, supports modern Python versions (3.10–3.14), and solves a real testing problem—automating Redis lifecycle management. The LGPLv3+ license is permissive for most use cases via the linking exception. No known vulnerabilities. Install if your test suite depends on Redis.
Install
pytest-redis on PyPI
pip
pip install pytest-redisuv
uv add pytest-redispoetry
poetry add pytest-redisInstalling pytest-redis
Before you install
Low friction install with active maintenance. Depends on pytest, port-for, mirakuru, and redis; all are standard testing/utility packages. Last release 167 days ago, repository active with recent commits.
License in practice
Licensed under LGPLv3+, a copyleft license. Derivative works and modifications must be released under compatible terms, but linking to the library from proprietary code is permitted under LGPL's linking exception.
Quickstart
pip install pytest-redis
import pytest
from pytest_redis import factories
def test_redis(redisdb):
redisdb.set('key', 'value')
assert redisdb.get('key') == b'value'
redis-server executable must be available on PATH or passed explicitly via --redis-exec; Redis must be installed locally or available in a container.
Verify before relying
- Whether the plugin supports Redis modules and extension loading in production scenarios beyond the documented test configuration.
- Performance characteristics when running many tests with redis_proc fixture across different scopes.
Package facts
| License | GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this… (full text in the JSON record) (copyleft) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — pytest, port-for, mirakuru, redis |
| Maintenance | actively maintained — 167 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 265,492/month — #8,324 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_redis-4.0.0-py3-none-any.whl
Keywords: tests, pytest, fixture, redis
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
pytest-rabbitmqA pytest plugin that provides fixtures to start…
copyleft · top 15,000 on PyPI
pytest-postgresqlA pytest plugin that provides fixtures to…
copyleft · top 5,000 on PyPI
pytest-sparkA pytest plugin that integrates Apache Spark…
permissive · top 15,000 on PyPI
pytest-docker-toolsProvides pytest fixture factories for…
permissive · top 5,000 on PyPI
pytest-datadirA pytest plugin that provides fixtures for…
permissive · top 5,000 on PyPI
pytest-shutilProvides pytest fixtures and utilities for…
permissive · top 15,000 on PyPI
pytest-mysqlA pytest plugin that provides MySQL and MariaDB…
copyleft · top 15,000 on PyPI
pytest-mock-resourcesProvides pytest fixtures that spin up real…
permissive · top 15,000 on PyPI
fixturesProvides a reusable fixture contract for unit…
permissive · top 15,000 on PyPI
pytest-deadfixturesA pytest plugin that identifies unused and…
permissive · top 5,000 on PyPI