Пример #1
0
def test_capture():

    with capture_log('info') as log:
        logger.warning('AA')
        logger.info('BB')

    msg1 = log[0]
    msg2 = log[1]

    assert 'flexx' in msg1
    assert 'AA' in msg1
    assert '[W ' in msg1

    assert 'flexx' in msg2
    assert 'BB' in msg2
    assert '[I' in msg2
Пример #2
0
def test_capture():

    with capture_log('info') as log:
        logger.warn('AA')
        logger.info('BB')

    msg1 = log[0]
    msg2 = log[1]

    assert 'flexx' in msg1
    assert 'AA' in msg1
    assert '[W ' in msg1

    assert 'flexx' in msg2
    assert 'BB' in msg2
    assert '[I' in msg2
Пример #3
0
def test_capture():
    
    with capture_log('info') as log:
        logger.warn('AA')
        logger.info('BB')
    
    msg1 = log[0]
    msg2 = log[1]
    
    assert 'flexx' in msg1
    assert 'AA' in msg1
    assert 'WARNING' in msg1
    
    assert 'flexx' in msg2
    assert 'BB' in msg2
    assert 'INFO' in msg2
Пример #4
0
 def caller_func_bla():
     logger.debug('AA foo')
     logger.info('BB bar')
Пример #5
0
def test_match():

    # Match based on string
    with capture_log('info', 'foo') as log:
        logger.info('AA foo')
        logger.info('BB bar')  # no foo
        logger.debug('CC foo')  # too high level
        logger.info('DD fXo')  # no foo

    assert len(log) == 1
    assert 'AA' in log[0]

    # Match based on regexp
    with capture_log('info', re.compile('f.o')) as log:
        logger.info('AA foo')
        logger.info('BB bar')  # no foo
        logger.debug('CC foo')  # too high level
        logger.info('DD fXo')

    assert len(log) == 2
    assert 'AA' in log[0]
    assert 'DD' in log[1]

    # No match
    with capture_log('info', '') as log:
        logger.info('AA foo')
        logger.info('BB bar')
        logger.debug('CC foo')  # too high level
        logger.info('DD fXo')

    assert len(log) == 3
Пример #6
0
def test_info():

    logger.info('test')
Пример #7
0
 def caller_func_bla():
     logger.debug('AA foo')
     logger.info('BB bar')
Пример #8
0
def test_match():

    # Match based on string
    with capture_log('info', 'foo') as log:
        logger.info('AA foo')
        logger.info('BB bar')  # no foo
        logger.debug('CC foo')  # too high level
        logger.info('DD fXo')  # no foo

    assert len(log) == 1
    assert 'AA' in log[0]

    # Match based on regexp
    with capture_log('info', re.compile('f.o')) as log:
        logger.info('AA foo')
        logger.info('BB bar')  # no foo
        logger.debug('CC foo')  # too high level
        logger.info('DD fXo')

    assert len(log) == 2
    assert 'AA' in log[0]
    assert 'DD' in log[1]

    # No match
    with capture_log('info', '') as log:
        logger.info('AA foo')
        logger.info('BB bar')
        logger.debug('CC foo')  # too high level
        logger.info('DD fXo')

    assert len(log) == 3
Пример #9
0
def test_info():

    logger.info('test')