def tearDown(self): handler = self.loghandler # All this is necessary to properly shut down the logging system and # avoid a regrtest complaint. Thanks to Vinay Sajip for the help. handler.close() logger.removeHandler(handler) for ref in weakref.getweakrefs(handler): logging._removeHandlerRef(ref) del self.loghandler logger.setLevel(self._old_level) super(LoggingCatcher, self).tearDown()
def setUp(self): super(LoggingCatcher, self).setUp() self.loghandler = handler = _TestHandler() self._old_level = logger.level logger.addHandler(handler) logger.setLevel(logging.DEBUG) # we want all messages