MCPcopy
hub / github.com/pytest-dev/pytest / test_deprecated_call_modes

Method test_deprecated_call_modes

testing/test_recwarn.py:208–224  ·  view source on GitHub ↗

Ensure deprecated_call() captures a deprecation warning as expected inside its block/function.

(self, warning_type, mode, call_f_first)

Source from the content-addressed store, hash-verified

206 @pytest.mark.parametrize("call_f_first", [True, False])
207 @pytest.mark.filterwarnings("ignore:hi")
208 def test_deprecated_call_modes(self, warning_type, mode, call_f_first) -> None:
209 """Ensure deprecated_call() captures a deprecation warning as expected inside its
210 block/function.
211 """
212
213 def f():
214 warnings.warn(warning_type("hi"))
215 return 10
216
217 # ensure deprecated_call() can capture the warning even if it has already been triggered
218 if call_f_first:
219 assert f() == 10
220 if mode == "call":
221 assert pytest.deprecated_call(f) == 10
222 else:
223 with pytest.deprecated_call():
224 assert f() == 10
225
226 def test_deprecated_call_specificity(self) -> None:
227 other_warnings = [

Callers

nothing calls this directly

Calls 1

fFunction · 0.70

Tested by

no test coverage detected