| Total Complexity | 1 |
| Total Lines | 21 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import unittest |
||
| 9 | class ListLogPrinterTest(unittest.TestCase): |
||
| 10 | |||
| 11 | def test_logging(self): |
||
| 12 | uut = ListLogPrinter() |
||
| 13 | ts = datetime.today() |
||
| 14 | ts_str = ts.strftime("%X") |
||
| 15 | |||
| 16 | uut.log_level = LOG_LEVEL.INFO |
||
| 17 | uut.warn("Test value", timestamp=ts) |
||
| 18 | uut.print("Test 2", timestamp=ts) # Should go to INFO |
||
| 19 | uut.debug("Test 2", timestamp=ts) # Should not be logged |
||
| 20 | |||
| 21 | self.assertEqual(uut.logs, |
||
| 22 | [LogMessage(LOG_LEVEL.WARNING, |
||
| 23 | "Test value", |
||
| 24 | timestamp=ts), |
||
| 25 | LogMessage(LOG_LEVEL.INFO, |
||
| 26 | "Test 2", |
||
| 27 | timestamp=ts)]) |
||
| 28 | |||
| 29 | self.assertRaises(TypeError, uut.log_message, "message") |
||
| 30 |