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

Function test_check_no_patched_repr

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

Source from the content-addressed store, hash-verified

904 reason="hypothesis may have monkeypatched _check_repr",
905)
906def test_check_no_patched_repr() -> None: # pragma: no cover
907 # We make `_check_repr` monkeypatchable to avoid this very ugly and verbose
908 # repr. The other tests that use `check` make use of `_check_repr` so they'll
909 # continue passing in case it is patched - but we have this one test that
910 # demonstrates just how nasty it gets otherwise.
911 match_str = (
912 r"^Raised exception group did not match: \n"
913 r"The following expected exceptions did not find a match:\n"
914 r" RaisesExc\(check=<function test_check_no_patched_repr.<locals>.<lambda> at .*>\)\n"
915 r" TypeError\n"
916 r"The following raised exceptions did not find a match\n"
917 r" ValueError\('foo'\):\n"
918 r" RaisesExc\(check=<function test_check_no_patched_repr.<locals>.<lambda> at .*>\): check did not return True\n"
919 r" `ValueError\(\)` is not an instance of `TypeError`\n"
920 r" ValueError\('bar'\):\n"
921 r" RaisesExc\(check=<function test_check_no_patched_repr.<locals>.<lambda> at .*>\): check did not return True\n"
922 r" `ValueError\(\)` is not an instance of `TypeError`$"
923 )
924 with (
925 pytest.raises(Failed, match=match_str),
926 RaisesGroup(RaisesExc(check=lambda x: False), TypeError),
927 ):
928 raise ExceptionGroup("", [ValueError("foo"), ValueError("bar")])
929
930
931def test_misordering_example() -> None:

Callers

nothing calls this directly

Calls 2

RaisesGroupClass · 0.90
RaisesExcClass · 0.90

Tested by

no test coverage detected