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

Function test_misordering_example

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

Source from the content-addressed store, hash-verified

929
930
931def test_misordering_example() -> None:
932 with (
933 fails_raises_group(
934 "\n"
935 "3 matched exceptions. \n"
936 "The following expected exceptions did not find a match:\n"
937 " RaisesExc(ValueError, match='foo')\n"
938 " It matches `ValueError('foo')` which was paired with `ValueError`\n"
939 " It matches `ValueError('foo')` which was paired with `ValueError`\n"
940 " It matches `ValueError('foo')` which was paired with `ValueError`\n"
941 "The following raised exceptions did not find a match\n"
942 " ValueError('bar'):\n"
943 " It matches `ValueError` which was paired with `ValueError('foo')`\n"
944 " It matches `ValueError` which was paired with `ValueError('foo')`\n"
945 " It matches `ValueError` which was paired with `ValueError('foo')`\n"
946 " RaisesExc(ValueError, match='foo'): Regex pattern did not match.\n"
947 " Expected regex: 'foo'\n"
948 " Actual message: 'bar'\n"
949 "There exist a possible match when attempting an exhaustive check, but RaisesGroup uses a greedy algorithm. Please make your expected exceptions more stringent with `RaisesExc` etc so the greedy algorithm can function."
950 ),
951 RaisesGroup(
952 ValueError, ValueError, ValueError, RaisesExc(ValueError, match="foo")
953 ),
954 ):
955 raise ExceptionGroup(
956 "",
957 [
958 ValueError("foo"),
959 ValueError("foo"),
960 ValueError("foo"),
961 ValueError("bar"),
962 ],
963 )
964
965
966def test_brief_error_on_one_fail() -> 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