import logging import unittest from tudelft_utilities_logging.ReportToLogger import ReportToLogger class ReportToLoggerTest(unittest.TestCase): def testSmoke(self): ReportToLogger("test") def testLogException(self): logger=ReportToLogger("test") # manually check that logged stacktrace originates from makeExc logger.log(logging.CRITICAL, "serious test", self.makeExc(3) ) def testLogNoException(self): logger=ReportToLogger("test") # manually check that logged stacktrace originates from makeExc logger.log(logging.WARNING, "a minor warning", None ) def makeExc(self, depth:int): if depth>0: return self.makeExc(depth-1) else: try: raise ValueError("blabla") except Exception as e: return e