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