Example #1
0
    def test_set(self):
        old = log.get_log_settings()
        log.set_debug('*:5')
        self.assertNotEqual(old, log.get_log_settings())

        log.set_log_settings(old)
        self.assertEqual(old, log.get_log_settings())
Example #2
0
    def test_own_log_handler_limited(self):
        """Checks our own log handler correctly mangles the message."""
        log.set_debug("testlog:%d" % log.INFO)
        log.add_log_handler(self.handler)

        self.tester.log("visible")
        self.assertEqual(self.message, 'override visible')
Example #3
0
    def test_format_strings(self):
        log.set_debug("testlog:%d" % log.INFO)
        log.add_limited_log_handler(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')
Example #4
0
    def test_limited_error(self):
        log.set_debug("testlog:%d" % log.ERROR)
        log.add_limited_log_handler(self.handler)

        self.tester.error("error")
        self.assertEqual(self.category, 'testlog')
        self.assertEqual(self.level, log.ERROR)
        self.assertEqual(self.message, 'error')
Example #5
0
    def test_log_handler(self):
        log.set_debug("testlog:%d" % log.INFO)
        log.add_log_handler(self.handler)

        self.tester.log("visible")
        self.assertEqual(self.message, 'visible')

        self.tester.warning("also visible")
        self.assertEqual(self.message, 'also visible')
Example #6
0
    def test_limited_visible(self):
        log.set_debug("testlog:%d" % log.INFO)
        log.add_limited_log_handler(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')
Example #7
0
    def test_limit_invisible(self):
        log.set_debug("testlog:%d" % log.INFO)
        log.add_limited_log_handler(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)
Example #8
0
    def test_log_handler_limited_levels(self):
        log.set_debug("testlog:%d" % log.INFO)
        log.add_limited_log_handler(self.handler)

        # now try debug and log again too
        log.set_debug("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')
Example #9
0
 def test_set_debug(self):
     log.set_debug(":5")
     log.set_debug("*")
     log.set_debug("5")