skillfed

pytest-dotenv

A py.test plugin that parses environment files before running tests

pytest-dotenv v0.5.2 5.5M downloads/30d#2,082 on PyPI210
Permissive license Abandoned released

What it is and what it does

pytest-dotenv is a pytest plugin that integrates python-dotenv to automatically load environment variables from .env files before tests run. It detects .env files in the working directory or ancestor directories and populates os.environ without overriding existing system variables by default. The plugin supports multiple configuration files (e.g., .env, .test.env, .deploy.env) defined in pytest config files like pytest.ini or tox.ini, and can be controlled via command-line flags.

The package depends on pytest and python-dotenv as its only runtime dependencies, making installation lightweight. However, it is archived and abandoned—the last release was in June 2020, and there have been no updates since. While it remains popular (top 5000 packages), the lack of maintenance means it may not be compatible with recent pytest or Python versions, and security or compatibility issues will not be addressed.

Use it for:

  • Load test-specific environment variables from .env files without modifying system environment during CI/CD pipelines
  • Manage multiple environment configurations (.env, .test.env, .deploy.env) for different test scenarios
  • Automatically populate pytest fixtures or test code with environment-based configuration without manual setup
  • Override environment variables selectively during test runs while preserving production settings in the base environment

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A pytest plugin that automatically loads environment variables from .env files before test runs, with support for multiple files and optional override of existing system variables.

No—not for new projects. The package is archived and abandoned since 2020, with no maintenance or security updates. While it may still work with older pytest and Python versions, there is significant risk of incompatibility with modern tooling. Consider using python-dotenv directly in your test fixtures or conftest.py, or look for actively maintained alternatives that provide the same functionality.

Install

pytest-dotenv on PyPI

pip

pip install pytest-dotenv

uv

uv add pytest-dotenv

poetry

poetry add pytest-dotenv

Installing pytest-dotenv

Before you install

Installation is straightforward with low friction. However, the package is archived and abandoned—the last release was in 2020, over 2250 days ago. While it has maintained a stable position in the top 5000 PyPI packages, no active maintenance means security updates or compatibility fixes are unlikely.

License in practice

Licensed under MIT (permissive), so there are no restrictions on commercial or private use, modification, or redistribution.

Quickstart

pip install pytest-dotenv

# In pytest.ini or tox.ini:
[pytest]
env_files = .env

# Or run: pytest --envfile .env

Requires pytest and python-dotenv as runtime dependencies; no known system-level blockers.

Verify before relying

  • Whether the package remains compatible with pytest versions released after 2020
  • Whether python-dotenv's API changes since 2020 affect this plugin's functionality
  • Active community forks or maintained alternatives that provide the same functionality

Package facts

License not declared (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 2 — pytest, python-dotenv
Maintenance abandoned — 2,250 days since the last release
Last repo commit (repository archived)
First released
Downloads 5,523,005/month — #2,082 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pytest_dotenv-0.5.2-py3-none-any.whl

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishProgramming Language :: Python :: 2Programming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8

Tags

pytest environment variablesload .env file pytestpytest dotenv pluginenvironment configuration testingpytest env file loaderpython-dotenv pytest integrationtest environment setup
archivedtest-configuration

More Testing packages