skillfed

pytest-env

pytest plugin that allows you to add environment variables.

pytest-env Permissive 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) Active 233 v1.7.0 released

Install

pytest-env on PyPI

pip

pip install pytest-env

uv

uv add pytest-env

poetry

poetry add pytest-env

Package 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: Libraries :: Python Modules

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.
pytest environment variables pluginload env vars from config filespytest dotenv integrationtest environment setup pytestpytest .env file loaderconfigure test environment variablespytest ini env variables

Similar packages