Skip to content

Respect explicit empty native env_files over INI fallback - #273

Merged
gaborbernat merged 2 commits into
pytest-dev:mainfrom
edsonsims:fix/native-empty-env-files
Oct 18, 2026
Merged

gaborbernat merged 2 commits into
pytest-dev:mainfrom
edsonsims:fix/native-empty-env-files

Conversation

@edsonsims

Copy link
Copy Markdown
Contributor

An explicit env_files = [] in native TOML still loads INI-style fallback files. For example, a pytest.toml with [pytest] env_files = ["fallback.env"] and [pytest_env] env_files = [] imports the variables from fallback.env. The same happens when extending configuration with --envfile +cli.env.

Keep absent native env_files as None, so omission preserves the INI fallback while an explicit empty list suppresses it. CLI files still load. Add subprocess regressions for pytest.toml, .pytest.toml, and adjacent pyproject.toml/pytest.ini, covering both omission and explicit emptiness with and without CLI extension.

Validation on macOS, Python 3.13.1 and pytest 9.1.1:

  • Before the fix: the new regression matrix had 6 failures and 6 passes.
  • After the fix: all 12 regression cases pass; full suite: 103 passed.
  • Coverage: 100% statements/branches under the repository configuration.
  • Ruff check, Ruff format check, and git diff --check pass.

AI assistance: OpenAI Codex drafted the change and performed automated review and the local checks above. No claim of owner manual review is made. Maintainer review is requested.

@gaborbernat
gaborbernat enabled auto-merge (squash) October 18, 2026 06:37
@gaborbernat
gaborbernat merged commit 1fed481 into pytest-dev:main Oct 18, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants