MCPcopy Index your code
hub / github.com/RustPython/RustPython / AssertRaises

Class AssertRaises

extra_tests/snippets/testutils.py:15–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13
14
15class AssertRaises:
16 def __init__(self, expected, msg):
17 self.expected = expected
18 self.exception = None
19 self.failmsg = msg
20
21 def __enter__(self):
22 return self
23
24 def __exit__(self, exc_type, exc_val, exc_tb):
25 if exc_type is None:
26 failmsg = self.failmsg or "{} was not raised".format(self.expected.__name__)
27 assert False, failmsg
28 if not issubclass(exc_type, self.expected):
29 return False
30
31 self.exception = exc_val
32 return True
33
34
35class TestFailingBool:

Callers 2

builtin_str.pyFile · 0.90
assert_raisesFunction · 0.85

Calls

no outgoing calls

Tested by 1

assert_raisesFunction · 0.68