Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider pyproject.toml files for config if no other config files were found #11962

Merged
merged 3 commits into from
Feb 14, 2024

Conversation

nicoddemus
Copy link
Member

@nicoddemus nicoddemus commented Feb 10, 2024

Today pyproject.toml is the standard for declaring a Python project root, so seems reasonable to consider it for the ini configuration (and specially rootdir) in case we do not find other suitable candidates.

Related to #11311

…e found

Today `pyproject.toml` is the standard for declaring a Python project root, so seems reasonable to consider it for the ini configuration (and specially `rootdir`) in case we do not find other suitable candidates.

Related to pytest-dev#11311
@nicoddemus nicoddemus marked this pull request as ready for review February 10, 2024 22:23
Comment on lines +180 to +181
Finally, a ``pyproject.toml`` file will be considered the ``configfile`` if no other match was found, in this case
even if it does not contain a ``[tool.pytest.ini_options]`` table (this was added in ``8.1``).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Finally, a ``pyproject.toml`` file will be considered the ``configfile`` if no other match was found, in this case
even if it does not contain a ``[tool.pytest.ini_options]`` table (this was added in ``8.1``).
Finally, a ``pyproject.toml`` file will be considered the ``configfile`` if no other match was found,
even if it does not contain a ``[tool.pytest.ini_options]`` table (this was added in ``8.1``). It will thus define the root dir.

It was unclear for me at first what the purpose of a pyproject.toml without any pytest related config inside was.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Used a slightly different approach, moving this to its own line as it is independent from pyproject.toml itself.

testing/test_config.py Outdated Show resolved Hide resolved
@nicoddemus nicoddemus merged commit acafd00 into pytest-dev:main Feb 14, 2024
24 checks passed
@nicoddemus nicoddemus deleted the pyproject-toml-root branch February 14, 2024 19:08
flying-sheep pushed a commit to flying-sheep/pytest that referenced this pull request Apr 9, 2024
…e found (pytest-dev#11962)

Today `pyproject.toml` is the standard for declaring a Python project root, so seems reasonable to consider it for the ini configuration (and specially `rootdir`) in case we do not find other suitable candidates.

Related to pytest-dev#11311
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.

3 participants