py.test plugin that allows you to add environment variables.
Project description
pytest-env
This is a pytest
plugin that enables you to set environment variables in a pytest.ini
or pyproject.toml
file.
Installation
Install with pip:
pip install pytest-env
Usage
In your pytest.ini file add a key value pair with env
as the key and the environment variables as a line separated
list of KEY=VALUE
entries. The defined variables will be added to the environment before any tests are run:
[pytest]
env =
HOME=~/tmp
RUN_ENV=test
Or with pyproject.toml
:
[tool.pytest.ini_options]
env = [
"HOME=~/tmp",
"RUN_ENV=test",
]
Only set if not already set
You can use D:
(default) as prefix if you don't want to override existing environment variables:
[pytest]
env =
D:HOME=~/tmp
D:RUN_ENV=test
Transformation
You can use existing environment variables using a python-like format, these environment variables will be expended before setting the environment variable:
[pytest]
env =
RUN_PATH=/run/path/{USER}
You can apply the R:
prefix to keep the raw value and skip this transformation step (can combine with the D:
flag,
order is not important):
[pytest]
env =
R:RUN_PATH=/run/path/{USER}
R:D:RUN_PATH_IF_NOT_SET=/run/path/{USER}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_env-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8faf927c6fcdbbc8fe3317506acc116713c9708d01652a0fd945f9ae27b71aa |
|
MD5 | a9121238823812f193ffc9ae8607f09b |
|
BLAKE2b-256 | ed458959fa18c5fc66dde8d2c2bb18b2cdc3da00b5f71c793135b7432bdbbe48 |