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

Function test_tuples

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

Source from the content-addressed store, hash-verified

1331
1332
1333def test_tuples() -> None:
1334 # raises has historically supported one of several exceptions being raised
1335 with pytest.raises((ValueError, IndexError)):
1336 raise ValueError
1337 # so now RaisesExc also does
1338 with RaisesExc((ValueError, IndexError)):
1339 raise IndexError
1340 # but RaisesGroup currently doesn't. There's an argument it shouldn't because
1341 # it can be confusing - RaisesGroup((ValueError, TypeError)) looks a lot like
1342 # RaisesGroup(ValueError, TypeError), and the former might be interpreted as the latter.
1343 with pytest.raises(
1344 TypeError,
1345 match=wrap_escape(
1346 "Expected a BaseException type, RaisesExc, or RaisesGroup, but got 'tuple'.\n"
1347 "RaisesGroup does not support tuples of exception types when expecting one of "
1348 "several possible exception types like RaisesExc.\n"
1349 "If you meant to expect a group with multiple exceptions, list them as separate arguments."
1350 ),
1351 ):
1352 RaisesGroup((ValueError, IndexError)) # type: ignore[call-overload]
1353
1354
1355def test_expected_matching_only_on_matching() -> None:

Callers

nothing calls this directly

Calls 3

RaisesExcClass · 0.90
RaisesGroupClass · 0.90
wrap_escapeFunction · 0.70

Tested by

no test coverage detected