Ensure deprecated_call() captures a deprecation warning as expected inside its block/function.
(self, warning_type, mode, call_f_first)
| 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 = [ |