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)
Example #2
0
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 testDebug():
  bl = BogusLogger()
  tl = TestingLogger()
  tlb = TestingLogger(bl)
  tl.debug("bug")
  tlb.debug("bug")
  assert (logging.DEBUG,'bug',()) == bl.item
  assert logging.DEBUG == tl.levels[0]
  assert logging.DEBUG == tlb.levels[0]
  assert 'bug' == tl.buffer[0]
  assert 'bug' == tlb.buffer[0]
Example #4
0
def testDebug():
    bl = BogusLogger()
    tl = TestingLogger()
    tlb = TestingLogger(bl)
    tl.debug("bug")
    tlb.debug("bug")
    assert (logging.DEBUG, 'bug', ()) == bl.item
    assert logging.DEBUG == tl.levels[0]
    assert logging.DEBUG == tlb.levels[0]
    assert 'bug' == tl.buffer[0]
    assert 'bug' == 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)
Example #6
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)
Example #8
0
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)