-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
plugin: warningsrelated to the warnings builtin pluginrelated to the warnings builtin plugintype: bugproblem that needs to be addressedproblem that needs to be addressed
Description
This is present in the latest pytest (and several previous versions I tried). If you have a function that calls a function that raises a warning then the contextmanager will not capture that warning properly...but only if you've called the function without wrapping it in deprecated_call
already.
import warnings
import pytest
def warn_me():
warnings.warn("deprecated", PendingDeprecationWarning, stacklevel=2)
def i_call_warn_me():
warn_me()
# Pass
def test_warn_me_check_deprecated_ctx_before_not_checking():
with pytest.deprecated_call():
i_call_warn_me()
# Pass
def test_warn_me_dont_check_warning():
i_call_warn_me()
# Fail
def test_warn_me_check_deprecated_ctx():
with pytest.deprecated_call():
i_call_warn_me()
# Pass
def test_warn_me_check_deprecated():
pytest.deprecated_call(i_call_warn_me)
alex and nicoddemus
Metadata
Metadata
Assignees
Labels
plugin: warningsrelated to the warnings builtin pluginrelated to the warnings builtin plugintype: bugproblem that needs to be addressedproblem that needs to be addressed