def METHOD_NAME(self, level=logging.DEBUG):
    th = TestHandler()
    th.setLevel(level)
    logger.addHandler(th)
    if self._test_handler is not None:
        l = len(self._test_handler.buffer)
    yield th.buffer
    if self._test_handler is not None:
        self._test_handler.buffer = self._test_handler.buffer[:l]