-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
plugin: warningsrelated to the warnings builtin pluginrelated to the warnings builtin plugintype: docsdocumentation improvement, missing or needing clarificationdocumentation improvement, missing or needing clarification
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 DeprecationWarnings 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: [].
Metadata
Metadata
Assignees
Labels
plugin: warningsrelated to the warnings builtin pluginrelated to the warnings builtin plugintype: docsdocumentation improvement, missing or needing clarificationdocumentation improvement, missing or needing clarification