Pytest plugin for testing code using Redis
Project description
pytest-redislite
pytest-redislite -- Is a simple pytest plugin to help you test your projects using Redis.
Features
- Automatically starts/ends Redis for your tests using Redislite
- Flash Redis Database between tests automatically
Requirements
- python >= 3.7
Installation
pytest-redislite should be installed using pip: ::
pip install pytest-redislite
Usage
When installed the plugin provides the fixture: redis_url
def test_code_with_redis(redis_url):
from redis import Redis
redis_client = Redis.from_url(redis_url)
redis_client.set('key', 'value')
assert redis_client.get('key', 'value')
When you are using the fixture Redis server will be started and finished after your tests.
Configuration
The plugins support pytest command line options:
--redis-path
: Specify a path to Redis Database file--redis-socket-path
: Specify a path to Redis Socket
as well as pytest ini
options:
redis_path
: Specify a path to Redis Database fileredis_socket_path
: Specify a path to Redis Socket
Auto flush data between tests
By default the plugin erases all data in Redis between tests. If you would like to change the behaviour define the fixture:
@pytest.fixture
def redis_autoflash():
return False
You may define it for a module or whole tests session.
Bug tracker
If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/pytest-redislite/issues
Contributing
Development of the project happens at: https://github.com/klen/pytest-redislite
License
Licensed under a MIT License
Project details
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-redislite-0.0.2.tar.gz
.
File metadata
- Download URL: pytest-redislite-0.0.2.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37b299fdcbe28dd9162ecc88acd262954ddd9e420a6b1304bc8ca24e687d85dc |
|
MD5 | 521b784673ed0b02752c05df9fa5c424 |
|
BLAKE2b-256 | 3138521934d6d4463de4daa57def609af31f49ce089e03c52331a9f333bb6550 |
File details
Details for the file pytest_redislite-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: pytest_redislite-0.0.2-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2736bcce3aeadd2f6aaddc3f242c90b08e9d67edfeb03ced2a9faf00bb93ab3 |
|
MD5 | 5a42f811bcc6076ad240b6d78f99c63e |
|
BLAKE2b-256 | a0da9161030fa7367955476386d5590f0ba56484866b1bae17945e5fc83dc633 |