def testLenFunction(): tl = TestingLogger() exp = 0 assert exp == len(tl) tl.debug('woo') exp += 1 assert exp == len(tl) tl.info('woo') exp += 1 assert exp == len(tl) tl.warning('woo') exp += 1 assert exp == len(tl) tl.warn('woo') exp += 1 assert exp == len(tl) tl.error('woo') exp += 1 assert exp == len(tl) tl.critical('woo') exp += 1 assert exp == len(tl) tl.fatal('woo') exp += 1 assert exp == len(tl)
def testInfo(): bl = BogusLogger() tl = TestingLogger() tlb = TestingLogger(bl) tl.info("info") tlb.info("info") assert (logging.INFO,'info',()) == bl.item assert logging.INFO == tl.levels[0] assert logging.INFO == tlb.levels[0] assert 'info' == tl.buffer[0] assert 'info' == tlb.buffer[0]
def testInfo(): bl = BogusLogger() tl = TestingLogger() tlb = TestingLogger(bl) tl.info("info") tlb.info("info") assert (logging.INFO, 'info', ()) == bl.item assert logging.INFO == tl.levels[0] assert logging.INFO == tlb.levels[0] assert 'info' == tl.buffer[0] assert 'info' == tlb.buffer[0]
def testStrFunction(): tl = TestingLogger() assert '' == str(tl) tl.debug('debug') expLines = ['DEBUG (10): debug'] tl.info('info') expLines.append('INFO (20): info') tl.warn('warn') expLines.append('WARNING (30): warn') tl.warning('warning') expLines.append('WARNING (30): warning') tl.error('error') expLines.append('ERROR (40): error') tl.critical('critical') expLines.append('FATAL (50): critical') tl.fatal('fatal') expLines.append('FATAL (50): fatal') expected = "\n".join(expLines) assert expected == str(tl)
def testClear(): tl = TestingLogger() tl.clear() assert 0 == len(tl) assert 0 == len(tl.levels) assert 0 == len(tl.buffer) tl.debug('woo') tl.info('woo') tl.warning('woo') tl.warn('woo') tl.error('woo') tl.critical('woo') tl.fatal('woo') assert 7 == len(tl) assert 7 == len(tl.levels) assert 7 == len(tl.buffer) tl.clear() assert 0 == len(tl) assert 0 == len(tl.levels) assert 0 == len(tl.buffer)