pytest-dotenv


Namepytest-dotenv JSON
Version 0.5.2 PyPI version JSON
download
home_pagehttps://github.com/quiqua/pytest-dotenv
SummaryA py.test plugin that parses environment files before running tests
upload_time2020-06-16 12:38:03
maintainer
docs_urlNone
authorMarcel Radischat
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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
```

### Alternative: Specify the file at the command line

You also have the option to run your tests with `py.test --envfile path/to/.env`.
This will load all defined environment variables and overwrite any existing ones regardless of the configuration `env_override_existing_values`.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/quiqua/pytest-dotenv",
    "name": "pytest-dotenv",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Marcel Radischat",
    "author_email": "marcel@quiqua.eu",
    "download_url": "https://files.pythonhosted.org/packages/cd/b0/cafee9c627c1bae228eb07c9977f679b3a7cb111b488307ab9594ba9e4da/pytest-dotenv-0.5.2.tar.gz",
    "platform": "",
    "description": "# pytest-dotenv\n\nThis 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.\n\n## Installation\n\nInstall the plugin with `pip`:\n\n```\n$ pip install pytest-dotenv\n```\n\n## Basic Usage\n\nIf 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.\n\n\n## Non-default configuration\n\n### Custom Environment Variable Files\n\nAdd a new section to a config file named `env_vars`.\nYou can list as many files as necessary:\n\n```\n[pytest]\nenv_files =\n    .env\n    .test.env\n    .deploy.env\n```\n\nThe files will be loaded and added to the `os.environ` dict object before\nany 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.\n\n### Overriding Existing Values\n\nBy default the plugin will not override any variables already defined in the\nprocess' environment. If you want that behavior, you have to use the\n`env_override_existing_values` setting:\n\n```\n[pytest]\nenv_override_existing_values = 1\nenv_files =\n    .env\n    .test.env\n    .deploy.env\n```\n\n### Alternative: Specify the file at the command line\n\nYou also have the option to run your tests with `py.test --envfile path/to/.env`.\nThis will load all defined environment variables and overwrite any existing ones regardless of the configuration `env_override_existing_values`.\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A py.test plugin that parses environment files before running tests",
    "version": "0.5.2",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "a10058f649421d79ed37f6d3eb137f78",
                "sha256": "40a2cece120a213898afaa5407673f6bd924b1fa7eafce6bda0e8abffe2f710f"
            },
            "downloads": -1,
            "filename": "pytest_dotenv-0.5.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a10058f649421d79ed37f6d3eb137f78",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3993,
            "upload_time": "2020-06-16T12:38:01",
            "upload_time_iso_8601": "2020-06-16T12:38:01.139172Z",
            "url": "https://files.pythonhosted.org/packages/d0/da/9da67c67b3d0963160e3d2cbc7c38b6fae342670cc8e6d5936644b2cf944/pytest_dotenv-0.5.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "bd8574925d1bf999824f01d04fffe292",
                "sha256": "2dc6c3ac6d8764c71c6d2804e902d0ff810fa19692e95fe138aefc9b1aa73732"
            },
            "downloads": -1,
            "filename": "pytest-dotenv-0.5.2.tar.gz",
            "has_sig": false,
            "md5_digest": "bd8574925d1bf999824f01d04fffe292",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3782,
            "upload_time": "2020-06-16T12:38:03",
            "upload_time_iso_8601": "2020-06-16T12:38:03.400855Z",
            "url": "https://files.pythonhosted.org/packages/cd/b0/cafee9c627c1bae228eb07c9977f679b3a7cb111b488307ab9594ba9e4da/pytest-dotenv-0.5.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-06-16 12:38:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "quiqua",
    "github_project": "pytest-dotenv",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pytest-dotenv"
}
        
Elapsed time: 0.01962s