(self, exc_type, exc_value, tb)
| 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 |
nothing calls this directly
no test coverage detected