Skip to main content

pytest-redis

Latest PyPI version Wheel Status Supported Python Versions License

Package status

Tests Coverage Status Requirements Status

What is this?

This is a pytest plugin, that enables you to test your code that relies on a running Redis database. It allows you to specify additional fixtures for Redis process and client.

How to use

Plugin contains two fixtures

  • redisdb - it’s a client fixture that has functional scope. After each test, it cleans Redis database for more reliable tests.

  • redis_proc - session scoped fixture, that starts Redis instance at it’s first use and stops at the end of the tests.

Simply include one of these fixtures into your tests fixture list.

You can also create additional redis client and process fixtures if you’d need to:

from pytest_redis import factories

redis_my_proc = factories.redis_proc(port=None, logsdir='/tmp')
redis_my = factories.redis('redis_my_proc')

Configuration

You can define your settings in three ways, it’s fixture factory argument, command line option and pytest.ini configuration option. You can pick which you prefer, but remember that these settings are handled in the following order:

  • Fixture factory argument

  • Command line option

  • Configuration option in your pytest.ini file

Redis option

Fixture factory argument

Command line option

pytest.ini option

Default

executable

executable

–redis-exec

redis_exec

/usr/bin/redis-server

host

host

–redis-host

redis_host

127.0.0.1

port

port

–redis-port

redis_port

random

connection timeout

timeout

–redis-timeout

redis_timeout

30

number of databases

db_count

–redis-db-count

redis_db_count

8

Whether to enable logging to the system logger

syslog

–redis-syslog

redis_syslog

False

Log directory location

logsdir

–redis-logsdir

redis_logsdir

$TMPDIR

Redis log verbosity level

loglevel

–redis-loglevel

redis_loglevel

notice

Compress dump files

compress

–redis-compress

redis_compress

True

Add checksum to RDB files

checksum

–redis-rdbcompress

redis_rdbchecksum

False

Save configuration

save

–redis-save

redis_save

“”

Example usage:

  • pass it as an argument in your own fixture

    redis_proc = factories.redis_proc(port=8888)
  • use --redis-port command line option when you run your tests

    py.test tests --redis-port=8888
  • specify your port as redis_port in your pytest.ini file.

    To do so, put a line like the following under the [pytest] section of your pytest.ini:

    [pytest]
    redis_port = 8888

Package resources

CHANGELOG

1.2.1

  • [bugfix] raise specific error in case the redis executable path has been misconfigured or does not exists

1.2.0

  • [feature] ability to configure syslog-enabled for redis in command line, pytest.ini or factory argument.

  • [feature] ability to configure rdbchecksum for redis in command line, pytest.ini or factory argument.

  • [feature] ability to configure rdbcompression for redis in command line, pytest.ini or factory argument.

  • [ehnacement] - RedisExecutor handling parameters and their translation to redis values if needed.

  • [feature] ability to configure save option for redis in command line, pytest.ini or factory argument.

1.1.1

  • [cleanup] removed path.py dependency

1.1.0

  • [feature] - migrate usage of getfuncargvalue to getfixturevalue. require at least pytest 3.0.0

1.0.0

  • [enhancements] removed the possibility to pass the custom config. No need to include one in package now.

  • [enhancements] command line, pytest.ini and fixture factory options for setting custom number of databases in redis

  • [enhancements] command line, pytest.ini and fixture factory options for redis log verbosity

  • [enhancements] command line, pytest.ini and fixture factory options for modifying connection timeout

  • [enhancements] command line and pytest.ini options for modifying executable

  • [enhancements] command line and pytest.ini options for modifying host

  • [enhancements] command line and pytest.ini options for modifying port

  • [enhancements] command line and pytest.ini options for modifying logs directory destination

Release files for pytest-redis 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-redis 1.2.1
File Size Uploaded
pytest-redis-1.2.1.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-redis 1.2.1
File Interpreter ABI Platform
pytest_redis-1.2.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 25.9 kB

Release files / pytest-redis-1.2.1.tar.gz

Download URL pytest-redis-1.2.1.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c11d013033f6332d575611c815bdad2100e7790d4b320f302a3cf98bc83038e2
BLAKE2b-256 checksum
How to use checksums
1a4772dc1fb04eadcd7677581060f8f22a56d2b5eca52a17995a7ab2ab2ea0a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pytest_redis-1.2.1-py2.py3-none-any.whl

Download URL pytest_redis-1.2.1-py2.py3-none-any.whl
Size 14.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a24d1ca6f70d59df78e3a016e5756a7d8009b91e803633423453075a4ea2f489
BLAKE2b-256 checksum
How to use checksums
566cd7e8ec31552fe3a2394cea98176401837df2de597e091213ae4d6e580454
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

5.0.0

2 release files

4.0.0

2 release files

3.1.3

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

1 release file

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page