()
| 406 | |
| 407 | |
| 408 | def test_check() -> None: |
| 409 | exc = ExceptionGroup("", (ValueError(),)) |
| 410 | |
| 411 | def is_exc(e: ExceptionGroup[ValueError]) -> bool: |
| 412 | return e is exc |
| 413 | |
| 414 | is_exc_repr = repr_callable(is_exc) |
| 415 | with RaisesGroup(ValueError, check=is_exc): |
| 416 | raise exc |
| 417 | |
| 418 | with ( |
| 419 | fails_raises_group( |
| 420 | f"check {is_exc_repr} did not return True on the ExceptionGroup" |
| 421 | ), |
| 422 | RaisesGroup(ValueError, check=is_exc), |
| 423 | ): |
| 424 | raise ExceptionGroup("", (ValueError(),)) |
| 425 | |
| 426 | def is_value_error(e: BaseException) -> bool: |
| 427 | return isinstance(e, ValueError) |
| 428 | |
| 429 | # helpful suggestion if the user thinks the check is for the sub-exception |
| 430 | with ( |
| 431 | fails_raises_group( |
| 432 | f"check {is_value_error} did not return True on the ExceptionGroup, but did return True for the expected ValueError. You might want RaisesGroup(RaisesExc(ValueError, check=<...>))" |
| 433 | ), |
| 434 | RaisesGroup(ValueError, check=is_value_error), |
| 435 | ): |
| 436 | raise ExceptionGroup("", (ValueError(),)) |
| 437 | |
| 438 | |
| 439 | def test_unwrapped_match_check() -> None: |
nothing calls this directly
no test coverage detected