Closed
Description
I have a test that ensures a specific warning type is produced by a function, but since I switched to pytest.warns
I no longer see Python 3.10 compatibility warnings in Pytest warnings summary
the code was emitting before switching to pytest.warns
. Is it expected behavior (in which case it contradicts https://docs.pytest.org/en/6.2.x/warnings.html#deprecationwarning-and-pendingdeprecationwarning) and how I can opt-out of hiding DeprecationWarning
s by pytest.warns
(there is nothing about that in the documentation https://docs.pytest.org/en/6.2.x/reference.html#pytest-warns)?
MVCE:
import pytest
import warnings
def test_warning():
with pytest.warns(DeprecationWarning):
with pytest.warns(UserWarning): # catches UserWarning, but also every other type too
warnings.warn("my warning", UserWarning)
warnings.warn("some deprecation warning", DeprecationWarning)
================================== FAILURES ===================================
________________________________ test_warning _________________________________
def test_warning():
> with pytest.warns(DeprecationWarning):
E Failed: DID NOT WARN. No warnings of type (<class 'DeprecationWarning'>,) was emitted. The list of emitted warnings is: [].