def testFormatStrings(self): log.setDebug("testlog:%d" % log.INFO) log.addLimitedLogHandler(self.handler) self.tester.info("%d %s", 42, 'the answer') self.assertEqual(self.category, 'testlog') self.assertEqual(self.level, log.INFO) self.assertEqual(self.message, '42 the answer')
def testLimitedError(self): log.setDebug("testlog:%d" % log.ERROR) log.addLimitedLogHandler(self.handler) self.tester.error("error") self.assertEqual(self.category, 'testlog') self.assertEqual(self.level, log.ERROR) self.assertEqual(self.message, 'error')
def testLimitedVisible(self): log.setDebug("testlog:%d" % log.INFO) log.addLimitedLogHandler(self.handler) # log 3 we should get self.tester.info("visible") self.assertEqual(self.category, 'testlog') self.assertEqual(self.level, log.INFO) self.assertEqual(self.message, 'visible') self.tester.warning("also visible") self.assertEqual(self.category, 'testlog') self.assertEqual(self.level, log.WARN) self.assertEqual(self.message, 'also visible')
def testLimitInvisible(self): log.setDebug("testlog:%d" % log.INFO) log.addLimitedLogHandler(self.handler) # log 2 we shouldn't get self.tester.log("not visible") self.assertFalse(self.category) self.assertFalse(self.level) self.assertFalse(self.message) self.tester.debug("not visible") self.assertFalse(self.category) self.assertFalse(self.level) self.assertFalse(self.message)
def testLogHandlerLimitedLevels(self): log.setDebug("testlog:%d" % log.INFO) log.addLimitedLogHandler(self.handler) # now try debug and log again too log.setDebug("testlog:%d" % log.LOG) self.tester.debug("debug") self.assertEqual(self.category, 'testlog') self.assertEqual(self.level, log.DEBUG) self.assertEqual(self.message, 'debug') self.tester.log("log") self.assertEqual(self.category, 'testlog') self.assertEqual(self.level, log.LOG) self.assertEqual(self.message, 'log')