(
exc_class: type[Exception],
arg: object,
func: Callable[P, T],
*args: P.args,
**kwargs: P.kwargs,
)
| 143 | |
| 144 | |
| 145 | def assertRaisesWithArg( |
| 146 | exc_class: type[Exception], |
| 147 | arg: object, |
| 148 | func: Callable[P, T], |
| 149 | *args: P.args, |
| 150 | **kwargs: P.kwargs, |
| 151 | ) -> None: |
| 152 | with pytest.raises(exc_class) as excinfo: |
| 153 | func(*args, **kwargs) |
| 154 | assert excinfo.value.args == (arg,) |
| 155 | |
| 156 | # Explicitly clear the Exception Info. Citing |
| 157 | # https://docs.pytest.org/en/latest/reference.html#pytest-raises: |
| 158 | # |
| 159 | # Clearing those references breaks a reference cycle |
| 160 | # (ExceptionInfo –> caught exception –> frame stack raising the exception |
| 161 | # –> current frame stack –> local variables –> ExceptionInfo) which makes |
| 162 | # Python keep all objects referenced from that cycle (including all local |
| 163 | # variables in the current frame) alive until the next cyclic garbage |
| 164 | # collection run. See the official Python try statement documentation for |
| 165 | # more detailed information. |
| 166 | del excinfo |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…