Skip to main content

Pytest plugin for testing async python code

Project description

pytest-redislite

pytest-redislite -- Is a simple pytest plugin to help you test your projects using Redis.

Tests Status [PYPI Version [Python Versions

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 file
  • redis_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 foe 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

pytest-redislite-0.0.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

pytest_redislite-0.0.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file pytest-redislite-0.0.0.tar.gz.

File metadata

  • Download URL: pytest-redislite-0.0.0.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.8.7

File hashes

Hashes for pytest-redislite-0.0.0.tar.gz
Algorithm Hash digest
SHA256 1e8c0aecbbb4986a4533e168fdc03df6629f53343697da3b8228178969f905f4
MD5 62e6ed5cc9aabd636d6eaec5d0ab5617
BLAKE2b-256 cb5b18e39c8acdcf259c6a867a50f0056d6f77514c744663fbf5b96fd220ba99

See more details on using hashes here.

File details

Details for the file pytest_redislite-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_redislite-0.0.0-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.8.7

File hashes

Hashes for pytest_redislite-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93c3e7322c1dd71101fac2e70b216cffd63d08ad7e23114bf5d320af8ea67f7e
MD5 5781b3dcdcc1e9278991aeff6a98b3c9
BLAKE2b-256 951575144820a7bb761aabd7c2c0840849fe6767f692f625fb77c150a5ffee65

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page