Rev | Line | |
---|
[207] | 1 | import logging
|
---|
[204] | 2 | import unittest
|
---|
[207] | 3 |
|
---|
| 4 | from tudelft_utilities_logging.ReportToLogger import ReportToLogger
|
---|
| 5 |
|
---|
| 6 |
|
---|
[204] | 7 | class ReportToLoggerTest(unittest.TestCase):
|
---|
| 8 | def testSmoke(self):
|
---|
| 9 | ReportToLogger("test")
|
---|
| 10 |
|
---|
| 11 | def testLogException(self):
|
---|
| 12 | logger=ReportToLogger("test")
|
---|
[949] | 13 | logger.log(logging.INFO, "all going ok")
|
---|
[204] | 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.