Skip to content

fix: custom TOML config files should use [pytest] section, not [tool.pytest]#14711

Closed
fazalpsinfo-cmyk wants to merge 1 commit into
pytest-dev:mainfrom
fazalpsinfo-cmyk:fix/toml-custom-config-section
Closed

fix: custom TOML config files should use [pytest] section, not [tool.pytest]#14711
fazalpsinfo-cmyk wants to merge 1 commit into
pytest-dev:mainfrom
fazalpsinfo-cmyk:fix/toml-custom-config-section

Conversation

@fazalpsinfo-cmyk

Copy link
Copy Markdown

When using a custom TOML config file via -c file.toml, the config loader incorrectly requires [tool.pytest] instead of [pytest]. Only pyproject.toml (which lives inside a project's tool table) should use the [tool.pytest] path.

This fix routes only pyproject.toml to the [tool.pytest] section; custom TOML files now correctly use [pytest].

Fixes #14705


Support my open source work: https://buymeacoffee.com/muhamedfazalps

…ction

When a custom TOML configuration file is passed via --config-file,
the code incorrectly looked for [tool.pytest] section (as used in
pyproject.toml). Custom config files should use [pytest] section,
matching the behavior of pytest.toml and documented expectations.

The else branch was changed to elif filepath.name == 'pyproject.toml'
so only pyproject.toml uses [tool.pytest]. A new else branch handles
any other custom .toml files by looking for [pytest] table.

Fixes pytest-dev#14705
@The-Compiler

Copy link
Copy Markdown
Member

Duplicate of #14707

@The-Compiler The-Compiler marked this as a duplicate of #14707 Jul 16, 2026
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.

--config-file incorrectly expects [tool.pytest] instead of [pytest] in TOML config on pytest 9

2 participants