def test_get_config_content_ver11(): """ Added for v1.1.0, ensure get_config_content() works with both v1.1.* and v1.0.* """ expected = { 'level': 'DEBUG', 'formatter': '{asctime} - {name} - {levelname} - {message}', 'stream': { 'type': 'StreamHandler', 'active': True, 'level': 'INFO' }, 'file': { 'type': 'FileHandler', 'active': False, 'level': 'DEBUG', 'filename': 'mylogpath/foo.log' }, 'null': { 'type': 'NullHandler', 'active': False, 'level': 'DEBUG' } } conf_content = get_config_content(__file__, 'ver11_config') assert conf_content == expected
def test_color_none_values(self): color_config = get_config_content(__file__, 'colors_null') logger = LogmeLogger(name='null_colors_logger', config=self.config, color_config=color_config) logger.info('info') logger.critical('critical')
def test_color_config_with_none_value(): """ Test for correct output when a value is None""" expected = { 'CRITICAL': {'color': 'PURPLE', 'style': 'Bold'}, 'ERROR': 'RED', 'WARNING': 'YELLOW', 'INFO': None, 'DEBUG': 'GREEN', } color_config = get_config_content(__file__, 'colors_test2') assert color_config == expected
def test_get_config_content_raise(): with pytest.raises(NoSectionError): get_config_content(__file__, 'blah')
def test_get_config_content(): conf_content = get_config_content(__file__, 'my_test_logger') assert type(conf_content) == dict assert type(conf_content['FileHandler']) == dict assert conf_content['level'] == 'INFO'
import pytest import logging from logme.color_provider import Color, ColorFormatter from logme.utils import get_color_config, get_config_content from logme.exceptions import InvalidColorConfig COLOR_CONFIG = get_color_config(__file__) NULL_COLOR_CONFIG = get_config_content(__file__, 'colors_null') @pytest.mark.parametrize('parse_args, result, text_style', [ pytest.param({'color': 'red'}, "\033[0;31m", {'color': '31'}, id='With color only, no style passed in'), pytest.param({ 'color': 'Blue', 'style': 'BOLD' }, "\033[0;1;34m", { 'color': '34', 'style': '1' }, id='With both color and style passed in, and cap on values'), pytest.param({'style': 'bold'}, "\033[0;1m", {'style': '1'}, id='With only style passed in'), pytest.param({ 'color': 'purple', 'style': 'underline',