Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pytest-redislite

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pytest-redislite

Pytest plugin for testing code using Redis

  • 0.1.0
  • PyPI
  • Socket score

Maintainers
1

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

Fixtures

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:


    @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

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc