def test_colors(tmpdir):
"""Test colors.
:param tmpdir: pytest fixture.
"""
script = dedent("""\
import logging
from sphinxcontrib.versioning.setup_logging import setup_logging
setup_logging(verbose=False, colors=True)
logger = logging.getLogger("{logger}")
logger.critical("Critical")
logger.error("Error")
logger.warning("Warning")
logger.info("Info")
logger.debug("Debug") # Not printed since verbose = False.
""").format(logger=ColorFormatter.SPECIAL_SCOPE + '.sample')
tmpdir.join('script.py').write(script)
output = pytest.run(tmpdir, [sys.executable, 'script.py'])
assert '\033[31m=> Critical\033[39m\n' in output
assert '\033[31m=> Error\033[39m\n' in output
assert '\033[33m=> Warning\033[39m\n' in output
assert '\033[36m=> Info\033[39m' in output
assert 'Debug' not in output
test_setup_logging.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录