Fix test failures with pytest-8.0.0 due to pytest.warns()
starting to work inside pytest.raises()
#8678
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change Summary
Fix the test suite problems that cause test failures with pytest-8.0.0, due to
pytest.warns()
being fixed to work insidepytest.raises()
.I've specifically:
pytest.warns()
when no warning could be produced because of invalid function call raisingTypeError
.pytest.warns()
assertion instead.This doesn't fix all the test failures reported in the linked bug, though.
test_validator_bad_fields_throws_configerror
fails due to changed exception representation, and I don't know how to clearly handle both versions.Additionally,
test_root_validator_allow_reuse_same_field
fails with the default-Werror
(I didn't include that in the bug), sincepytest.warns()
passes the warning through. However, adding a secondpytest.warns()
to check for that breaks the test with older pytest versions, where the warning is captured by the otherpytest.warns()
.Related issue number
Fix #8674
Checklist
Selected Reviewer: @hramezani