创建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 loggingdef test_01():logging.info('这是测试用例01的info...')logging.warning('这是测试用例01的warning...')logging.error('这是测试用例01的error...')assert 1 == 1if __name__ == '__main__':pytest.main(['-v','test_case.py'])