def test_timeout(self): throttledlog.throttle('test', 10, timeout=7) for i in range(12): throttledlog.debug('test', "Cycle: %s", i) throttledlog.monotonic_time.time += 1.0 self.assertEqual(throttledlog._logger.messages, ['Cycle: %s' % (i,) for i in (0, 7, 10,)])
def test_default(self): throttledlog.throttle('test', 3) for i in range(5): throttledlog.debug('other', "Cycle: %s", i) self.assertEqual(throttledlog._logger.messages, ['Cycle: %s' % (i, ) for i in range(5)])
def test_no_logging(self): throttledlog.throttle('test', 3) for i in range(5): throttledlog.debug('test', "Cycle: %s", i) self.assertEqual(throttledlog._logger.messages, [])
def test_default(self): throttledlog.throttle("test", 3) for i in range(5): throttledlog.debug("other", "Cycle: %s", i) self.assertEqual(throttledlog._logger.messages, ["Cycle: %s" % (i,) for i in range(5)])
def test_no_logging(self): throttledlog.throttle("test", 3) for i in range(5): throttledlog.debug("test", "Cycle: %s", i) self.assertEqual(throttledlog._logger.messages, [])
def test_default(self): throttledlog.throttle('test', 3) for i in range(5): throttledlog.debug('other', "Cycle: %s", i) self.assertEqual(throttledlog._logger.messages, ['Cycle: %s' % (i,) for i in range(5)])
def test_throttled_logging(self): throttledlog.throttle('test', 3) for i in range(5): throttledlog.debug('test', "Cycle: %s", i) self.assertEqual(throttledlog._logger.messages, ['Cycle: 0', 'Cycle: 3'])