Skip to main content

pytest-env

PyPI Supported Python versions check Code style: black Downloads

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}

Metadata

Release files for pytest-env 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-env 0.8.1
File Size Uploaded
pytest_env-0.8.1.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-env 0.8.1
File Interpreter ABI Platform
pytest_env-0.8.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.2 kB

Release files / pytest_env-0.8.1.tar.gz

Download URL pytest_env-0.8.1.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d7b2f5273ec6d1e221757998bc2f50d2474ed7d0b9331b92556011fadc4e9abf
BLAKE2b-256 checksum
How to use checksums
a3102be3d3ef39212ee94407779260311a6d48e5d484aa4597308c6037878089
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / pytest_env-0.8.1-py3-none-any.whl

Download URL pytest_env-0.8.1-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c0605ae09a5b7e41c20ebcc44f2c906eea9654095b4b0c342b3814bcc3a8492
BLAKE2b-256 checksum
How to use checksums
d70acbd49d36bad40b1b62729a189c42ad3b4b76ea91968a361a72acb8676b14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release history Release notifications | RSS feed

1.7.1

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.8.2

2 release files

This release

0.8.1 This release

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.2

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.1

1 release file

0.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page