MCPcopy
hub / github.com/python/mypy / assertRaises

Function assertRaises

mypyc/test-data/fixtures/testutil.py:45–52  ·  view source on GitHub ↗
(typ: type, msg: str = '')

Source from the content-addressed store, hash-verified

43
44@contextmanager
45def assertRaises(typ: type, msg: str = '') -> Iterator[None]:
46 try:
47 yield
48 except BaseException as e:
49 assert type(e) is typ, f"{e!r} is not a {typ.__name__}"
50 assert msg in str(e), f'Message "{e}" does not match "{msg}"'
51 else:
52 assert False, f"Expected {typ.__name__} but got no exception"
53
54def assertDomainError() -> Any:
55 return assertRaises(ValueError, "math domain error")

Callers 2

assertDomainErrorFunction · 0.85
assertMathRangeErrorFunction · 0.85

Calls 2

typeClass · 0.85
strClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…