创建pytest.ini 文件
[pytest]
log_file =pytest_log.txt
log_file_level = INFO
log_file_date_format = %Y-%m-%d %H:%M:%S
log_file_format = %(asctime)s | %(filename)s | %(funcName)s | line:%(lineno)d | %(levelname)s | %(message)s
import pytest
import logging
def test_01():
logging.info('这是测试用例01的info...')
logging.warning('这是测试用例01的warning...')
logging.error('这是测试用例01的error...')
assert 1 == 1
if __name__ == '__main__':
pytest.main(['-v','test_case.py'])
文章来源:https://www.toymoban.com/news/detail-684495.html
文章来源地址https://www.toymoban.com/news/detail-684495.html
到了这里,关于pytest pytest.ini 配置日志输出至文件的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!