Skip to main content

Pytest plugin for testing code using Redis

Project description


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

Tests Status PYPI Version Python Versions


  • Automatically starts/ends Redis for your tests using Redislite
  • Flash Redis Database between tests automatically


  • python >= 3.7


pytest-redislite should be installed using pip:

pip install pytest-redislite


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.


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


The plugin provides the fixtures:

  • redis_server (session scope) provides an instance of redislite.Redis. The fixture manages the server's lifetime (start, shutdown).
  • redis_url (session scope) Starts redislite server and provides the server's socket address.
  • redis_factory (session scope) a context manager to start/shutdown redislite server.

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:

    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


Development of the project happens at:


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.1.0.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

pytest_redislite-0.1.0-py3-none-any.whl (3.3 kB view hashes)

Uploaded Python 3

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