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

Method __exit__

Lib/unittest/case.py:267–292  ·  view source on GitHub ↗
(self, exc_type, exc_value, tb)

Source from the content-addressed store, hash-verified

265 return self
266
267 def __exit__(self, exc_type, exc_value, tb):
268 if exc_type is None:
269 try:
270 exc_name = self.expected.__name__
271 except AttributeError:
272 exc_name = str(self.expected)
273 if self.obj_name:
274 self._raiseFailure("{} not raised by {}".format(exc_name,
275 self.obj_name))
276 else:
277 self._raiseFailure("{} not raised".format(exc_name))
278 else:
279 traceback.clear_frames(tb)
280 if not issubclass(exc_type, self.expected):
281 # let unexpected exceptions pass through
282 return False
283 # store exception, without traceback, for later retrieval
284 self.exception = exc_value.with_traceback(None)
285 if self.expected_regex is None:
286 return True
287
288 expected_regex = self.expected_regex
289 if not expected_regex.search(str(exc_value)):
290 self._raiseFailure('"{}" does not match "{}"'.format(
291 expected_regex.pattern, str(exc_value)))
292 return True
293
294 __class_getitem__ = classmethod(types.GenericAlias)
295

Callers

nothing calls this directly

Calls 6

strFunction · 0.85
issubclassFunction · 0.85
_raiseFailureMethod · 0.80
with_tracebackMethod · 0.80
formatMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected