Conditionally check if a warning is raised
(condition: bool, category: type[Warning], message: str)
| 153 | |
| 154 | @contextlib.contextmanager |
| 155 | def _check_warning(condition: bool, category: type[Warning], message: str): |
| 156 | """Conditionally check if a warning is raised""" |
| 157 | if condition: |
| 158 | import pytest |
| 159 | |
| 160 | with pytest.warns(category, match=message) as ctx: |
| 161 | yield ctx |
| 162 | else: |
| 163 | with contextlib.nullcontext() as ctx: |
| 164 | yield ctx |
no outgoing calls
no test coverage detected