RLTest - Redis Modules Test Framework

raw JSON →
0.7.25 verified Fri May 01 auth: no python maintenance

RLTest is a test framework for Redis modules, allowing developers to run tests on Redis and modules across various environments (containers, local, cloud). The current version is 0.7.25, with maintenance mode status. It is a core tool in the Redis module ecosystem, receiving occasional updates.

pip install rltest
error ModuleNotFoundError: No module named 'rltest'
cause rltest package not installed.
fix
Run: pip install rltest
error AttributeError: 'RLTest' object has no attribute 'run'
cause Using old pattern where RLTest.run() is not available; need to use the function-based style.
fix
Update to new pattern: define a function and call RLTestEnv.run_tests() or use pytest.
error redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection refused.
cause Default Redis server is not running; RLTest can't spin up an instance if 'redis_binary' not configured.
fix
Install a local Redis or set TestEnvConfig(redis_binary='/usr/bin/redis-server') to start an embedded server.
deprecated RLTest now recommends using pytest-based approach (pytest-rltest) instead of traditional RLTest classes. The standalone RLTest class may be deprecated in future releases.
fix Consider using pytest integration: pip install pytest-rltest and write test functions with pytest fixtures.
gotcha Missing 'module_path' or 'binary_path' in TestEnvConfig will cause the environment to fail silently or use default Redis (without module). Always set at least one.
fix Explicitly set module_path, binary_path, or use a pre-existing Redis instance via connection_params.
gotcha EnvConfig (deprecated) vs TestEnvConfig: Older code uses EnvConfig, but it's deprecated. Using EnvConfig may break in newer versions.
fix Use TestEnvConfig from rltest.config (though often imported directly from rltest).

Minimal RLTest usage: configure module path, create environment, define tests, run.

from rltest import RLTest, TestEnvConfig

# Create environment configuration
env_config = TestEnvConfig(
    module_path='/path/to/your/module.so',
    redis_port=6379
)

# Create test instance
rt = RLTest(env_config)

# Define your test method
def test_my_module():
    client = rt.env.get_redis_connection()
    assert client.ping()

# Run tests
if __name__ == '__main__':
    rt.run()