def test_warning():
with warnings.catch_warnings():
warnings.simplefilter("error")
...
However, in #6076, I decided not to add warnings.simplefilter("error"). I've now concluded that was a mistake, and that this doesn't turn warnings into errors as intended - if I add warnings.warn("This should cause a failure"), the test suite still passes. Restoring simplefilter, only then does it fail like it should.
https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests states
However, in #6076, I decided not to add
warnings.simplefilter("error")
. I've now concluded that was a mistake, and that this doesn't turn warnings into errors as intended - if I addwarnings.warn("This should cause a failure")
, the test suite still passes. Restoringsimplefilter
, only then does it fail like it should.