skillfed

pytest-redis

Redis fixtures and fixture factories for Pytest.

pytest-redis v4.0.0 265.5K downloads/30d#8,324 on PyPI104
Copyleft 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) Active released

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-redis

uv

uv add pytest-redis

poetry

poetry add pytest-redis

Installing 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

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)Natural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Testing

Tags

pytest redis fixturesredis testing plugintest redis databasepytest redis processredis test fixturesredis integration testingpytest redis client
redis-testingpytest-pluginfixture-factory

More Python Modules packages