MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_can_capture_previously_warned

Method test_can_capture_previously_warned

testing/test_recwarn.py:396–404  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

394
395 @pytest.mark.filterwarnings("ignore")
396 def test_can_capture_previously_warned(self) -> None:
397 def f() -> int:
398 warnings.warn(UserWarning("ohai"))
399 return 10
400
401 assert f() == 10
402 assert pytest.warns(UserWarning, f) == 10
403 assert pytest.warns(UserWarning, f) == 10
404 assert pytest.warns(UserWarning, f) != "10" # type: ignore[comparison-overlap]
405
406 def test_warns_context_manager_with_kwargs(self) -> None:
407 with pytest.raises(TypeError) as excinfo:

Callers

nothing calls this directly

Calls 1

fFunction · 0.70

Tested by

no test coverage detected