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

Method __exit__

Lib/unittest/_log.py:64–87  ·  view source on GitHub ↗
(self, exc_type, exc_value, tb)

Source from the content-addressed store, hash-verified

62 return handler.watcher
63
64 def __exit__(self, exc_type, exc_value, tb):
65 self.logger.handlers = self.old_handlers
66 self.logger.propagate = self.old_propagate
67 self.logger.setLevel(self.old_level)
68
69 if exc_type is not None:
70 # let unexpected exceptions pass through
71 return False
72
73 if self.no_logs:
74 # assertNoLogs
75 if len(self.watcher.records) > 0:
76 self._raiseFailure(
77 "Unexpected logs found: {!r}".format(
78 self.watcher.output
79 )
80 )
81
82 else:
83 # assertLogs
84 if len(self.watcher.records) == 0:
85 self._raiseFailure(
86 "no logs of level {} or higher triggered on {}"
87 .format(logging.getLevelName(self.level), self.logger.name))

Callers

nothing calls this directly

Calls 3

_raiseFailureMethod · 0.80
setLevelMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected