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

Last change on this file since 207 was 207, checked in by wouter, 3 years ago

#87 trying to work around the python library namespaces

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