MCPcopy Index your code
hub / github.com/python/cpython / __exit__

Method __exit__

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected