Giter VIP home page Giter VIP logo

pytest-dotenv's Introduction

pytest-dotenv

This little plugin uses python-dotenv to load any environment variables from a .env file. Extra configuration can be defined in any pytest config files, such as pytest.ini, tox.ini and so on.

Installation

Install the plugin with pip:

$ pip install pytest-dotenv

Basic Usage

If all you want is to load environment variables from a .env file then installing the plugin is all that is needed. python-dotenv will automatically detect your .env file and load it. By default, the plugin won't override any existing system variables.

Non-default configuration

Custom Environment Variable Files

Add a new section to a config file named env_vars. You can list as many files as necessary:

[pytest]
env_files =
    .env
    .test.env
    .deploy.env

The files will be loaded and added to the os.environ dict object before any tests are run. If the files are not found on the working directory, it will search for the files in the ancestor directory and upwards.

Overriding Existing Values

By default the plugin will not override any variables already defined in the process' environment. If you want that behavior, you have to use the env_override_existing_values setting:

[pytest]
env_override_existing_values = 1
env_files =
    .env
    .test.env
    .deploy.env

pytest-dotenv's People

Contributors

frob avatar mpessas avatar vladimir-iliev avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.