栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

pytest之pytest.ini配置项

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

pytest之pytest.ini配置项

参考文献:

pytest 配置文件
【pytest】pytest配置文件pytest.ini详解_Bug 挖掘机的博客-CSDN博客
pytest.ini配置 pytest–配置 - 邹邹很busy。 - 博客园
Pytest常用命令
pytest的warning处理机制

配置项:
  • console_output_style
[pytest]
console_output_style = classic  #经典样式
console_output_style = progress #带有进度指示器的经典演示
console_output_style = count   #像progress,但将进度显示为已完成的测试数,而不是百分比
  • markers:它的作用是做注册标记,防止拼写错误,标记自定义的mark

  • testpaths:用于限定测试用例的搜索范围。只有在pytest未指定文件目录参数或测试用例标识符时,该选项才有作用

[pytest]
testpaths = test_001  #(指定测试用例搜索目录,优先于norecursedirs)
norecursedirs = .* venv test_001 *.egg dist build  #(忽略测试用例搜索目录test_001)
  • 更改测试搜索的规则,哪些范围的用例将被执行
[pytest]
python_classes = *Test Test* *Suite
python_files = test_* *_test check_*
​python_functions = test_* check_*
  • 禁用用例:设置xfail_strict = true将会使那些被标记为@pytest.mark.xfail但实际通过的测试用例也被报告为失败
    xfail_strict = true
[pytest]
xfail_strict = true   #实际通过的测试用例也被报告为失败
xpass_strict = true   #实际失败的测试用例也被报告为通过
  • addopts:更改默认命令行选项,经常要用到某些参数,又不想重复输入
[pytest]
console_output_style = progress
python_files = test*.py
addopts =  -vv   #以更详细的显示运行结果。
;         -m configMarker   #被标记为configMarker的用例
          --disable-warnings  # 禁用所有warnings,通常不使用,禁用范围过大
;         --capture=sys
          --alluredir allure_results   #allure报告路径
          --maxfail=2 -rf      # 2个用例失败后退出,病给出详细信息

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/835650.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号