Skip to content

Conversation

sgaist
Copy link
Contributor

@sgaist sgaist commented Oct 7, 2025

Add a warning when pytest.ini and pyproject.toml are present

The behaviour does not change however users will be notified that pytest.ini is selected over pyproject.toml and any configuration related to pytest it may contain.

Fixes #13330

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 7, 2025
@sgaist sgaist force-pushed the add-warning-on-pytest-ini-and-pyproject-presence branch from caf5ef7 to fce5184 Compare October 7, 2025 19:15
The behaviour does not change however users will be notified that
pytest.ini is selected over pyproject.toml and any configuration
related to pytest it may contain.
@sgaist sgaist force-pushed the add-warning-on-pytest-ini-and-pyproject-presence branch from fce5184 to 5ff1af4 Compare October 7, 2025 19:29
@sgaist
Copy link
Contributor Author

sgaist commented Oct 7, 2025

I am unsure what to do to satisfy codecov. Any hint would be appreciated.

Copy link
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

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

Thanks for working on this.

I haven't thought yet whether we really want this, but in any case a couple of comments:

We should not emit a warning if pyproject.toml exists but without a pytest section. That's very common and expected and not ambiguous (please also add a test for this case).

Also, it will be better not to have the "should warn" logic in terminal.py, it shouldn't know about config stuff itself. Ideally (I think) the core config file search logic should indicate whether need to warn.

Doing so, Terminal does not need to know anything about
the configuration files.
@sgaist
Copy link
Contributor Author

sgaist commented Oct 7, 2025

@bluetech I should have kept my original implementation which was following your suggestion minus the verification of the content of the pyproject.toml file.

I refactored the code following your suggestion.

@sgaist sgaist requested a review from bluetech October 7, 2025 21:16
Do it the other way around, check if the file suffix is ini
rather than listing the possible names.
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.

Warn if both pytest.ini (.pytest.ini) and pyproject.toml with pytest ops exist
2 participants