Skip to content

Fix custom TOML config files passed with -c#14707

Open
DebadityaHait wants to merge 1 commit into
pytest-dev:mainfrom
DebadityaHait:agent/fix-custom-toml-config
Open

Fix custom TOML config files passed with -c#14707
DebadityaHait wants to merge 1 commit into
pytest-dev:mainfrom
DebadityaHait:agent/fix-custom-toml-config

Conversation

@DebadityaHait

@DebadityaHait DebadityaHait commented Jul 14, 2026

Copy link
Copy Markdown

Closes #14705.

Summary

load_config_dict_from_file previously treated every TOML filename other than pytest.toml and .pytest.toml like pyproject.toml, so a custom file passed with -c ignored its documented [pytest] table.

This change reserves [tool.pytest] and [tool.pytest.ini_options] for pyproject.toml. Other TOML configuration files now read native options from [pytest]. It also adds direct loader and CLI collection regression coverage and documents the custom-file format.

Testing

  • python -m pytest testing/test_findpaths.py testing/test_config.py -q (281 passed, 1 xfailed)
  • pre-commit run --files AUTHORS changelog/14705.bugfix.rst doc/en/reference/customize.rst src/_pytest/config/findpaths.py testing/test_config.py testing/test_findpaths.py
  • sphinx-build -j auto -W --keep-going -b html doc/en doc/en/_build/html
  • Manual pytest -c pytest-benchmark.toml --collect-only -q reproduction (1 test collected)

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.

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

1 participant