pytest 打印日志

详细可参考

logging配置

https://blog.csdn.net/zyz511919766/article/details/25136485

pytest中输出日志

https://www.cnblogs.com/landhu/p/9910460.html

简单的example

def test_logging():
    # logging.basicConfig(level=logging.DEBUG,
    #                     format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
    #                     datefmt='%a, %d %b %Y %H:%M:%S',
    #                     filename='/tmp/test.log',
    #                     filemode='w')
    logging.basicConfig(level=logging.DEBUG)
    logging.debug('debug message')
    logging.info('info message')
    logging.warning('warning message')
    logging.error('error message')
    logging.critical('critical message')

pycharm中的 Additional Arguments设置为 -s --capture=no -o log_cli=true -o log_cli_level=DEBUGpytest 打印日志_第1张图片

 

 

 

你可能感兴趣的:(开发工具,#,pycharm,pytest,pycharm)