(self)
| 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: |