import pytest
import logging


@pytest.mark.parametrize('level',
                         [logging.DEBUG,
                          logging.INFO,
                          logging.WARNING,
                          logging.CRITICAL,
                          logging.ERROR])
def test_simple_logging(level, struct_logger, handler):
    levelname = logging.getLevelName(level)
    msg = "TEST"
    struct_logger.__getattribute__(levelname.lower())(msg)
    record = handler.pop()
    assert record.msg == msg
    assert record.levelname == levelname


@pytest.mark.parametrize('level',
                         [logging.DEBUG,
                          logging.INFO,
                          logging.WARNING,
                          logging.CRITICAL,
                          logging.ERROR])
def test_simple_log(level, struct_logger, handler):
    levelname = logging.getLevelName(level)
    msg = "TEST"
    struct_logger.log(level, msg)
    record = handler.pop()
    assert record.msg == msg
    assert record.levelname == levelname


def test_simple_exception(struct_logger, handler):
    msg = "TEST"
    e = None
    try:
        e = Exception
        raise e
    except Exception:
        struct_logger.exception(msg)
    record = handler.pop()
    assert record.msg == msg
    assert record.levelname == logging.getLevelName(logging.ERROR)
    assert record.exc_info[0] == e


def test_simple_string_format_msg(struct_logger, handler):
    msg = "TEST {}"
    sub = "SUB_TEST"
    struct_logger.debug(msg, sub)
    record = handler.pop()
    assert record.msg == msg
    assert sub in record.args


def test_simple_extra(struct_logger, handler):
    msg = "TEST"
    struct_logger.debug(msg, extra={'TEST': 'TEST'})
    record = handler.pop()
    assert record.msg == msg
    assert 'TEST' in record.__dict__
    assert record.TEST == 'TEST'

@@ -24,24 +24,270 @@
 ogging%0D%0A%0D%0A%0D%0A
+def level_mapper(obj, level):%0D%0A    func_mapper = %7B%0D%0A        'DEBUG': obj.debug,%0D%0A        'INFO': obj.info,%0D%0A        'WARNING': obj.warning,%0D%0A        'CRITICAL': obj.critical,%0D%0A        'ERROR': obj.error%0D%0A    %7D%0D%0A    return func_mapper%5Blevel%5D%0D%0A%0D%0A%0D%0A
 @pytest.mark
@@ -652,39 +652,36 @@
     
-struct_logger.__getattribute__(
+level_mapper(struct_logger, 
 leve
@@ -689,16 +689,8 @@
 name
-.lower()
 )(ms

fix getattribute for python 2.6 (try #2)