()
| 34 | |
| 35 | |
| 36 | def test_raises_group() -> None: |
| 37 | with pytest.raises( |
| 38 | TypeError, |
| 39 | match=wrap_escape("Expected a BaseException type, but got 'int'"), |
| 40 | ): |
| 41 | RaisesExc(5) # type: ignore[call-overload] |
| 42 | with pytest.raises( |
| 43 | ValueError, |
| 44 | match=wrap_escape("Expected a BaseException type, but got 'int'"), |
| 45 | ): |
| 46 | RaisesExc(int) # type: ignore[type-var] |
| 47 | with pytest.raises( |
| 48 | TypeError, |
| 49 | match=wrap_escape( |
| 50 | "Expected a BaseException type, RaisesExc, or RaisesGroup, but got an exception instance: ValueError", |
| 51 | ), |
| 52 | ): |
| 53 | RaisesGroup(ValueError()) # type: ignore[call-overload] |
| 54 | with RaisesGroup(ValueError): |
| 55 | raise ExceptionGroup("foo", (ValueError(),)) |
| 56 | |
| 57 | with ( |
| 58 | fails_raises_group("`SyntaxError()` is not an instance of `ValueError`"), |
| 59 | RaisesGroup(ValueError), |
| 60 | ): |
| 61 | raise ExceptionGroup("foo", (SyntaxError(),)) |
| 62 | |
| 63 | # multiple exceptions |
| 64 | with RaisesGroup(ValueError, SyntaxError): |
| 65 | raise ExceptionGroup("foo", (ValueError(), SyntaxError())) |
| 66 | |
| 67 | # order doesn't matter |
| 68 | with RaisesGroup(SyntaxError, ValueError): |
| 69 | raise ExceptionGroup("foo", (ValueError(), SyntaxError())) |
| 70 | |
| 71 | # nested exceptions |
| 72 | with RaisesGroup(RaisesGroup(ValueError)): |
| 73 | raise ExceptionGroup("foo", (ExceptionGroup("bar", (ValueError(),)),)) |
| 74 | |
| 75 | with RaisesGroup( |
| 76 | SyntaxError, |
| 77 | RaisesGroup(ValueError), |
| 78 | RaisesGroup(RuntimeError), |
| 79 | ): |
| 80 | raise ExceptionGroup( |
| 81 | "foo", |
| 82 | ( |
| 83 | SyntaxError(), |
| 84 | ExceptionGroup("bar", (ValueError(),)), |
| 85 | ExceptionGroup("", (RuntimeError(),)), |
| 86 | ), |
| 87 | ) |
| 88 | |
| 89 | |
| 90 | def test_incorrect_number_exceptions() -> None: |
nothing calls this directly
no test coverage detected