Warn if both pytest.ini (.pytest.ini) and pyproject.toml with pytest ops exist #13330
Labels
topic: reporting
related to terminal output and user-facing messages and errors
type: enhancement
new feature or API change, should be merged into features branch
What's the problem this feature will solve?
I was going absolutely batty about why my
pyproject.toml
pytest options, particularlyfilterwarnings
settings weren't actually filtering some warnings. The document on the capture warnings mentions both options to configure and since I had ours in pyproject.toml, that's what I was tweaking values in.Eventually I put breakpoints in the pytest code for handling warnings (in
_pytest/warnings.py
) and realized that the pytest config had NONE of ourtool.pytest.ini_options
available and was using some other random set. Wondering if I had something misformatted inpyproject.toml
, I checked the configuration docs and realized that pytest.ini would result in pyproject.toml settings being entirely ignored. Removing it fixed my filter warnings issues.Describe the solution you'd like
A warning when pytest starts up and detects multiple sources of configuration exists as this is almost certainly not intentional. Especially as more people put everything in their pyproject.toml, this "obvious" rake is easy to step on. Note that there is output like this at pytest startup:
But given how much things can print to the terminal when running tests, it can easily run off screen especially if you add prints and other things to debug and be easily missed. Possibly just changing this to this output when the ignored config is detected:
Alternative Solutions
Other possible mitigations:
Additional context
Yes, I missed multiple indicators that this misconfiguration existed!
The text was updated successfully, but these errors were encountered: