Rev | Line | |
---|
[949] | 1 | import logging
|
---|
| 2 | import unittest
|
---|
| 3 |
|
---|
| 4 | from tudelft_utilities_logging.ReportToFile import ReportToFile
|
---|
| 5 |
|
---|
| 6 |
|
---|
| 7 | class 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.