Skip to content

Error on top-level options in pytest.toml#14646

Open
vismaytiwari wants to merge 2 commits into
pytest-dev:mainfrom
vismaytiwari:fix-pytest-toml-top-level-options
Open

Error on top-level options in pytest.toml#14646
vismaytiwari wants to merge 2 commits into
pytest-dev:mainfrom
vismaytiwari:fix-pytest-toml-top-level-options

Conversation

@vismaytiwari

@vismaytiwari vismaytiwari commented Jun 23, 2026

Copy link
Copy Markdown

Closes #14638.

Summary

  • Keep the [pytest] table required in pytest.toml and .pytest.toml.
  • Raise a clear configuration error when either file contains top-level scalar options without a [pytest] table, instead of silently ignoring them.
  • Continue allowing empty pytest.toml files.
  • Add regression coverage and update the changelog.

Verification

  • Manually reproduced the original behavior before the change: top-level addopts was silently ignored.
  • Verified the updated behavior with a small project: top-level addopts = ["-v"] exits with code 4 and reports that configuration must be under [pytest].
  • Verified an empty pytest.toml remains valid and the sample test passes.
  • SETUPTOOLS_SCM_PRETEND_VERSION=9.2.0.dev0 uv run --no-project --with-editable . --with '.[dev]' --python 3.11 python -m pytest testing/test_config.py -q (256 passed, 1 xfailed)
  • uvx --from pre-commit==4.4.0 pre-commit run --files src/_pytest/config/findpaths.py testing/test_config.py doc/en/reference/customize.rst changelog/14638.bugfix.rst

@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jun 23, 2026
@vismaytiwari vismaytiwari marked this pull request as ready for review June 23, 2026 11:57
@vismaytiwari vismaytiwari changed the title Read top-level options in pytest.toml Error on top-level options in pytest.toml Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pytest.toml without section header leads to silently ignored options

1 participant