Exemplo n.º 1
0
def test_logger_no_loglist():
    mylog = logger.getChild('testing')
    msg = 'Some error happend here.'
    lh = ListHandler()
    check.is_instance(lh.log_list, list)
    mylog.addHandler(lh)
    mylog.error(msg)
    check.equal(lh.log_list[0], msg)
Exemplo n.º 2
0
def test_logger_list_debug():
    mylog = logger.getChild('testing')
    logs = []
    log_to_list(mylog, logs)
    mylog.setLevel('DEBUG')
    mylog.warn('Warning test')
    mylog.error('Error test')
    mylog.info('Info test')
    mylog.debug('Debug test')
    check.equal(mylog.name, 'astropop.testing')
    check.equal(len(logs), 4)
Exemplo n.º 3
0
def test_logger_remove_handler():
    mylog = logger.getChild('testing')
    msg = 'Some error happend here.'
    logs = []
    lh = log_to_list(mylog, logs)
    mylog.setLevel('DEBUG')
    mylog.error(msg)
    check.is_instance(lh, ListHandler)
    check.is_in(lh, mylog.handlers)
    mylog.removeHandler(lh)
    check.is_not_in(lh, mylog.handlers)
    check.equal(logs[0], msg)
    check.equal(lh.log_list[0], msg)
    check.equal(lh.log_list, logs)
Exemplo n.º 4
0
def test_logger_list_only_messagens(level, expected):
    mylog = logger.getChild('testing')
    logs = []
    log_to_list(mylog, logs, full_record=False)
    mylog.setLevel(level)
    mylog.error('Error test')
    mylog.warn('Warning test')
    mylog.info('Info test')
    mylog.debug('Debug test')
    check.equal(mylog.name, 'astropop.testing')
    check.equal(len(logs), expected)
    for i, k in zip(['Error test', 'Warning test', 'Info test',
                     'Debug test'][0:expected], logs):
        check.equal(i, k)
Exemplo n.º 5
0
 def test_logger_list_only_messagens(self, level, expected):
     mylog = logger.getChild('testing')
     logs = []
     log_to_list(mylog, logs, full_record=False)
     mylog.setLevel(level)
     mylog.error('Error test %i', 40)
     mylog.warning('Warning test %i', 30)
     mylog.info('Info test %i', 20)
     mylog.debug('Debug test %i', 10)
     assert_equal(mylog.name, 'astropop.testing')
     assert_equal(len(logs), expected)
     for i, k in zip(['Error test 40', 'Warning test 30', 'Info test 20',
                      'Debug test 10'][0:expected], logs):
         assert_equal(i, k)
Exemplo n.º 6
0
 def test_logger_list_defaults(self, level, expected):
     mylog = logger.getChild('testing')
     logs = []
     log_to_list(mylog, logs)
     mylog.setLevel(level)
     mylog.error('Error test')
     mylog.warning('Warning test')
     mylog.info('Info test')
     mylog.debug('Debug test')
     assert_equal(mylog.name, 'astropop.testing')
     assert_equal(len(logs), expected)
     for i, k in zip(['Error test', 'Warning test', 'Info test',
                     'Debug test'][0:expected],
                     logs):
         assert_equal(i, k)
Exemplo n.º 7
0
def test_logger_list_full_record(level, expected):
    mylog = logger.getChild('testing')
    logs = []
    log_to_list(mylog, logs, full_record=True)
    mylog.setLevel(level)
    mylog.error('Error test')
    mylog.warn('Warning test')
    mylog.info('Info test')
    mylog.debug('Debug test')
    check.equal(mylog.name, 'astropop.testing')
    check.equal(len(logs), expected)
    for i, k, n in zip(['Error', 'Warning', 'Info', 'Debug'][0:expected], logs,
                       [40, 30, 20, 10][0:expected]):
        check.equal(f'{i} test', k.msg)
        check.equal(k.name, 'astropop.testing')
        check.equal(k.levelno, n)
        check.equal(k.levelname, i.upper())