source: loggingpy/test/tudelft_utilities_logging/ReportToFileTest.py@ 1404

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

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

File size: 912 bytes
RevLine 
[949]1import logging
2import unittest
3
4from tudelft_utilities_logging.ReportToFile import ReportToFile
5
6
7class ReportToLoggerTest(unittest.TestCase):
8 def testSmoke(self):
9 ReportToFile("test")
10
11 def testLogException(self):
12 logger=ReportToFile("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=ReportToFile("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.