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

Function test_identity_oopsies

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

Source from the content-addressed store, hash-verified

1009
1010
1011def test_identity_oopsies() -> None:
1012 # it's both possible to have several instances of the same exception in the same group
1013 # and to expect multiple of the same type
1014 # this previously messed up the logic
1015
1016 with (
1017 fails_raises_group(
1018 "3 matched exceptions. `RuntimeError()` is not an instance of `TypeError`"
1019 ),
1020 RaisesGroup(ValueError, ValueError, ValueError, TypeError),
1021 ):
1022 raise ExceptionGroup(
1023 "", [ValueError(), ValueError(), ValueError(), RuntimeError()]
1024 )
1025
1026 e = ValueError("foo")
1027 m = RaisesExc(match="bar")
1028 with (
1029 fails_raises_group(
1030 "\n"
1031 "The following expected exceptions did not find a match:\n"
1032 " RaisesExc(match='bar')\n"
1033 " RaisesExc(match='bar')\n"
1034 " RaisesExc(match='bar')\n"
1035 "The following raised exceptions did not find a match\n"
1036 " ValueError('foo'):\n"
1037 " RaisesExc(match='bar'): Regex pattern did not match.\n"
1038 " Expected regex: 'bar'\n"
1039 " Actual message: 'foo'\n"
1040 " RaisesExc(match='bar'): Regex pattern did not match.\n"
1041 " Expected regex: 'bar'\n"
1042 " Actual message: 'foo'\n"
1043 " RaisesExc(match='bar'): Regex pattern did not match.\n"
1044 " Expected regex: 'bar'\n"
1045 " Actual message: 'foo'\n"
1046 " ValueError('foo'):\n"
1047 " RaisesExc(match='bar'): Regex pattern did not match.\n"
1048 " Expected regex: 'bar'\n"
1049 " Actual message: 'foo'\n"
1050 " RaisesExc(match='bar'): Regex pattern did not match.\n"
1051 " Expected regex: 'bar'\n"
1052 " Actual message: 'foo'\n"
1053 " RaisesExc(match='bar'): Regex pattern did not match.\n"
1054 " Expected regex: 'bar'\n"
1055 " Actual message: 'foo'\n"
1056 " ValueError('foo'):\n"
1057 " RaisesExc(match='bar'): Regex pattern did not match.\n"
1058 " Expected regex: 'bar'\n"
1059 " Actual message: 'foo'\n"
1060 " RaisesExc(match='bar'): Regex pattern did not match.\n"
1061 " Expected regex: 'bar'\n"
1062 " Actual message: 'foo'\n"
1063 " RaisesExc(match='bar'): Regex pattern did not match.\n"
1064 " Expected regex: 'bar'\n"
1065 " Actual message: 'foo'"
1066 ),
1067 RaisesGroup(m, m, m),
1068 ):

Callers

nothing calls this directly

Calls 3

RaisesGroupClass · 0.90
RaisesExcClass · 0.90
fails_raises_groupFunction · 0.85

Tested by

no test coverage detected