Redis fixtures and fixture factories for Pytest.
Project description
pytest-redis
Package 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
redis - 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 |
Log directory location |
logsdir |
–redis-logsdir |
redis_logsdir |
$TMPDIR |
Redis log verbosity level |
loglevel |
–redis-loglevel |
redis_loglevel |
notice |
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
Bug tracker: https://github.com/ClearcodeHQ/pytest-redis/issues
CHANGELOG
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytest-redis-1.1.0.tar.gz
.
File metadata
- Download URL: pytest-redis-1.1.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d3ea11e971a3739f4c8cab2eb20bc07a5c57a14ed24d8f0122ee28a9e6cadad |
|
MD5 | ed873abd62477e87bc7efc0cc83a9d6c |
|
BLAKE2b-256 | 879587601ae896cead01d44938aca0c919ec764f9562cd09f1386099b72db93a |
File details
Details for the file pytest_redis-1.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pytest_redis-1.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73e4b797d89558e3cff901c7d7f824af34d88ce8aad77ee1de1542f65ce0f5c7 |
|
MD5 | fd18139f8a2d8724fff3a2dce8cdc54b |
|
BLAKE2b-256 | 758a47ca9739e4e3e35eb9c68bf20667a1238502f891d261488e32018083e035 |