source: loggingpy/test/tudelft_utilities_logging/ReportToLoggerTest.py@ 949

Last change on this file since 949 was 949, checked in by wouter, 4 months ago

#321 loggging python 1.1.0 now includes ReportToFile and ReportToLog now writes to stdout.

File size: 922 bytes
Line 
1import logging
2import unittest
3
4from tudelft_utilities_logging.ReportToLogger import ReportToLogger
5
6
7class ReportToLoggerTest(unittest.TestCase):
8 def testSmoke(self):
9 ReportToLogger("test")
10
11 def testLogException(self):
12 logger=ReportToLogger("test")
13 logger.log(logging.INFO, "all going ok")
14 # manually check that logged stacktrace originates from makeExc
15 logger.log(logging.CRITICAL, "serious test", self.makeExc(3) )
16
17 def testLogNoException(self):
18
19 logger=ReportToLogger("test")
20 # manually check that logged stacktrace originates from makeExc
21 logger.log(logging.WARNING, "a minor warning", None )
22
23 def makeExc(self, depth:int):
24 if depth>0:
25 return self.makeExc(depth-1)
26 else:
27 try:
28 raise ValueError("blabla")
29 except Exception as e:
30 return e
Note: See TracBrowser for help on using the repository browser.