python-pillow / Pillow

Python Imaging Library (Fork)
https://python-pillow.org
Other
12.32k stars 2.23k forks source link

Fixed catching warnings #8505

Closed radarhere closed 3 weeks ago

radarhere commented 3 weeks ago

https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests states

To ensure that no warnings are emitted, use:

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.