pytest-env
pytest plugin that allows you to add environment variables.
Install
pytest-env on PyPI
pip
pip install pytest-envuv
uv add pytest-envpoetry
poetry add pytest-envPackage facts
| License | MIT License Copyright (c) 2010-202x The pytest-env developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — pytest, python-dotenv, tomli |
| Maintenance | actively maintained — 23 days since the last release |
| Last repo commit | |
| First released | |
| Popularity | one of the top 1,000 most-downloaded packages on PyPI (30-day window, as of 2026-08-13) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-13) |
Evidence: pytest_env-1.7.0-py3-none-any.whl
Keywords: env, pytest
About pytest-env
from the package's own PyPI description — quoted content, verbatim
pytest-env
PyPI (image) Supported Python versions (image) check (image) Downloads (image)
A pytest plugin that sets environment variables from pyproject.toml, pytest.toml, .pytest.toml, or pytest.ini
configuration files. It can also load variables from .env files.
<!-- mdformat-toc start --slug=github --no-anchors --maxlevel=6 --minlevel=2 -->
Read as markdown · JSON record · Source repository · Homepage
AI interpretation — verify before relying
AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page
A pytest plugin that injects environment variables into test runs from configuration files (pyproject.toml, pytest.ini, or .env files), with support for variable expansion and conditional assignment.
Low friction: pure Python wheel with only three runtime dependencies (pytest, python-dotenv, tomli), all widely used. Actively maintained with a release 23 days ago and last commit August 2026.
MIT License permits unrestricted use, modification, and distribution with only attribution required—no restrictions on commercial or proprietary use.
Usage
pip install pytest-env
# Add to pyproject.toml:
# [tool.pytest_env]
# DATABASE_URL = "postgresql://localhost/test_db"
import os
import pytest
def test_env():
assert os.environ["DATABASE_URL"] == "postgresql://localhost/test_db"
Requires pytest as a runtime dependency; Python ≥3.10.
Verdict: Mature, actively maintained pytest plugin with zero known vulnerabilities and permissive MIT licensing. Low install friction and broad Python version support (3.10–3.15) make it a reliable choice for test environment configuration. Well-suited for projects needing flexible environment variable management across different test contexts.
Needs verification
- Whether the plugin's configuration file discovery (walking up directory tree) works as expected in monorepo or nested project structures.
- Performance impact when loading many environment variables or large .env files in CI/CD pipelines.
Similar packages
permissive · top 100 on PyPI
envierpermissive · top 1,000 on PyPI
pypermissive · top 1,000 on PyPI
hatch-vcspermissive · top 1,000 on PyPI
setuptools-scmpermissive · top 1,000 on PyPI
tomlipermissive · top 1,000 on PyPI
tomlkitpermissive · top 1,000 on PyPI
ConfigArgParsepermissive · top 1,000 on PyPI
tomli-wpermissive · top 1,000 on PyPI
pyrightpermissive · top 1,000 on PyPI