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

Function test_brief_error_on_one_fail

testing/python/raises_group.py:966–1008  ·  view source on GitHub ↗

If only one raised and one expected fail to match up, we print a full table iff the raised exception would match one of the expected that previously got matched

()

Source from the content-addressed store, hash-verified

964
965
966def test_brief_error_on_one_fail() -> None:
967 """If only one raised and one expected fail to match up, we print a full table iff
968 the raised exception would match one of the expected that previously got matched"""
969 # no also-matched
970 with (
971 fails_raises_group(
972 "1 matched exception. `TypeError()` is not an instance of `RuntimeError`"
973 ),
974 RaisesGroup(ValueError, RuntimeError),
975 ):
976 raise ExceptionGroup("", [ValueError(), TypeError()])
977
978 # raised would match an expected
979 with (
980 fails_raises_group(
981 "\n"
982 "1 matched exception. \n"
983 "The following expected exceptions did not find a match:\n"
984 " RuntimeError\n"
985 "The following raised exceptions did not find a match\n"
986 " TypeError():\n"
987 " It matches `Exception` which was paired with `ValueError()`\n"
988 " `TypeError()` is not an instance of `RuntimeError`"
989 ),
990 RaisesGroup(Exception, RuntimeError),
991 ):
992 raise ExceptionGroup("", [ValueError(), TypeError()])
993
994 # expected would match a raised
995 with (
996 fails_raises_group(
997 "\n"
998 "1 matched exception. \n"
999 "The following expected exceptions did not find a match:\n"
1000 " ValueError\n"
1001 " It matches `ValueError()` which was paired with `ValueError`\n"
1002 "The following raised exceptions did not find a match\n"
1003 " TypeError():\n"
1004 " `TypeError()` is not an instance of `ValueError`"
1005 ),
1006 RaisesGroup(ValueError, ValueError),
1007 ):
1008 raise ExceptionGroup("", [ValueError(), TypeError()])
1009
1010
1011def test_identity_oopsies() -> None:

Callers

nothing calls this directly

Calls 2

RaisesGroupClass · 0.90
fails_raises_groupFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…