MCPcopy
hub / github.com/pytest-dev/pytest / test_raisesexc_match

Function test_raisesexc_match

testing/python/raises_group.py:1123–1158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1121
1122
1123def 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
1161def test_RaisesExc_check() -> None:

Callers

nothing calls this directly

Calls 3

RaisesGroupClass · 0.90
RaisesExcClass · 0.90
fails_raises_groupFunction · 0.85

Tested by

no test coverage detected