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

Method test_can_capture_previously_warned

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

Source from the content-addressed store, hash-verified

456
457 @pytest.mark.filterwarnings("ignore")
458 def test_can_capture_previously_warned(self) -> None:
459 def f() -> int:
460 warnings.warn(UserWarning("ohai"))
461 return 10
462
463 assert f() == 10
464 assert pytest.warns(UserWarning, f) == 10
465 assert pytest.warns(UserWarning, f) == 10
466 assert pytest.warns(UserWarning, f) != "10" # type: ignore[comparison-overlap]
467
468 def test_warns_context_manager_with_kwargs(self) -> None:
469 with pytest.raises(TypeError) as excinfo:

Callers

nothing calls this directly

Calls 1

fFunction · 0.70

Tested by

no test coverage detected