pytest配置文件ini

 

 

 

总结 pytest.ini

  • 修改用例的命名规则
  • 配置日志格式,比代码配置更方便
  • 指定执行目录
  • 排除搜索目录
  • 添加标签,防止运行过程报警告错误
  • 添加默认参数

注意:windows下要去掉所有的中文,不然会出现编码问题

报错:UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xaa in position 15

pytest.ini

[pytest]
;下面为配置不同运行规则
;run cases files with check_* and test_* titles,执行check_开头和 test_开头的所有的文件,后面一定要加*
python_files = check_* test_*
;run test class with Check* and Test* titles,执行所有的以Test和Check开头的类
python_classes = Test*  Check*
;run test function with check_* and test_* titles,执行所有以test_和check_开头的方法
python_functions= test_* check_*


;addopts设置默认运行pytest命令时带上的参数
;addopts = -vs

;设置执行的路径
testpaths = bilibili baidu
;忽略某些文件夹/目录
norecursedirs = result logs datas test_demo*

;日志设置
;日志开关 true false
log_cli = true
;日志级别
log_cli_level = info
;打印详细日志,相当于命令行加 -vs
addopts = --capture=no
;日志格式
log_cli_format = %(asctime)s [%(levelname)s] %(message)s (%(filename)s:%(lineno)s)
;日志时间格式
log_cli_date_format = %Y-%m-%d %H:%M:%S
;日志文件位置
log_file = ./log/test.log
;日志文件等级
log_file_level = info
;日志文件格式
log_file_format = %(asctime)s [%(levelname)s] %(message)s (%(filename)s:%(lineno)s)
;日志文件日期格式
log_file_date_format = %Y-%m-%d %H:%M:%S

 

posted @   lms21  阅读(69)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示