Skip to content

Keep pyproject environment settings visible beside native pytest configuration - #260

Merged
gaborbernat merged 4 commits into
pytest-dev:mainfrom
oyeong011:fix/pytest-env-regression
Sep 8, 2026
Merged

gaborbernat merged 4 commits into
pytest-dev:mainfrom
oyeong011:fix/pytest-env-regression

Conversation

@oyeong011

Copy link
Copy Markdown
Contributor

Problem and change

A native pytest.toml containing only [pytest] settings prevents pytest-env from discovering [tool.pytest_env] in the adjacent pyproject.toml. Continue discovery only when the pytest_env section is absent. An explicitly empty section, including env_files = [], still stops discovery and prevents sibling or parent environment settings from being inherited.

Verification

  • Original no-section regression failed before the change and passes afterward.
  • Additional subprocess regressions verify that empty sections and env_files = [] preserve precedence at sibling/parent boundaries.
  • Full suite: 80 passed, exit 0.
  • Public pytest subprocess QA: 5 passed, exit 0; all child pytest processes exit 0.
  • Ruff check/format and git diff --check passed.

Tested on macOS, Python 3.12.13 and pytest 9.1.1. Other platforms and Python versions were not tested.

AI assistance: OpenAI Codex drafted and checked this change. All reported commands were run locally.

…iguration

Confidence: high
Scope-risk: narrow
Tested: Regression fails before fix and passes after; full suite results recorded externally
Not-tested: Other operating systems and Python versions
Constraint: The first TOML file containing pytest_env wins even when empty
Tested: Four new subprocess regressions fail before fix; full suite 80 passed; five discovery QA cases passed; Ruff clean
Confidence: high
Scope-risk: narrow
Subprocess regressions left the empty-section branch unmeasured, so CI
failed its 100% coverage requirement. Run them through pytester's
in-process harness and cover hidden files and sibling and parent
precedence.
@gaborbernat
gaborbernat merged commit 7ddd152 into pytest-dev:main Sep 8, 2026
11 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