()
| 1121 | |
| 1122 | |
| 1123 | def test_raisesexc_match() -> None: |
| 1124 | with RaisesGroup(RaisesExc(ValueError, match="foo")): |
| 1125 | raise ExceptionGroup("", (ValueError("foo"),)) |
| 1126 | with ( |
| 1127 | fails_raises_group( |
| 1128 | "RaisesExc(ValueError, match='foo'): Regex pattern did not match.\n" |
| 1129 | " Expected regex: 'foo'\n" |
| 1130 | " Actual message: 'bar'" |
| 1131 | ), |
| 1132 | RaisesGroup(RaisesExc(ValueError, match="foo")), |
| 1133 | ): |
| 1134 | raise ExceptionGroup("", (ValueError("bar"),)) |
| 1135 | |
| 1136 | # Can be used without specifying the type |
| 1137 | with RaisesGroup(RaisesExc(match="foo")): |
| 1138 | raise ExceptionGroup("", (ValueError("foo"),)) |
| 1139 | with ( |
| 1140 | fails_raises_group( |
| 1141 | "RaisesExc(match='foo'): Regex pattern did not match.\n" |
| 1142 | " Expected regex: 'foo'\n" |
| 1143 | " Actual message: 'bar'" |
| 1144 | ), |
| 1145 | RaisesGroup(RaisesExc(match="foo")), |
| 1146 | ): |
| 1147 | raise ExceptionGroup("", (ValueError("bar"),)) |
| 1148 | |
| 1149 | # check ^$ |
| 1150 | with RaisesGroup(RaisesExc(ValueError, match="^bar$")): |
| 1151 | raise ExceptionGroup("", [ValueError("bar")]) |
| 1152 | with ( |
| 1153 | fails_raises_group( |
| 1154 | "\nRaisesExc(ValueError, match='^bar$'): \n - barr\n ? -\n + bar" |
| 1155 | ), |
| 1156 | RaisesGroup(RaisesExc(ValueError, match="^bar$")), |
| 1157 | ): |
| 1158 | raise ExceptionGroup("", [ValueError("barr")]) |
| 1159 | |
| 1160 | |
| 1161 | def test_RaisesExc_check() -> None: |
nothing calls this directly
no test coverage detected