目的: 自动获取pytest case执行结果和caseid 存为变量,后续可以和case管理工具集成

@pytest.hookimpl(hookwrapper=True, tryfirst=True)

def pytest_runtest_makereport(item, call):

out = yield
print("Case result is: - ", out)
report = out.get_result()

if report.when == "call":
print("test report: %s" % report)
print("test step: %s" % report.when)
print("nodeid: %s" % report.nodeid)
# print("description is : %s" % str(item.function.__doc__))
print("execute result: %s" % report.outcome)

global Case_Result, Case_Name, Case_ID

case_result = (True if report.outcome == "passed" else False) # case执行结果转换成boolean 类型
Case_Result = case_result

case_name = report.nodeid.split("::")[-1]  # 获取 testcase name, nodeid: testcase/SmartSharedList/test_SmartSharedList.py::Test_SmartSharedList::test_TC_13096_ARM4329_56789
case_id = case_name.split("_")[-3] # 获取caseID, test_TC_13096_ARM4329_56789
Case_Name = case_name
Case_ID = case_id

#  Upload result to qtest through caseid and result
print("Upload result to qtest")

最新文章

  1. 【python】用setup安装自定义模块和包
  2. PHP常用功能
  3. 网站标题ico那些事
  4. [Asp.net]c#中的斜杠和反斜杠
  5. windows设置java环境变量
  6. Graph database_neo4j 底层存储结构分析(7)
  7. Leetcode: Lexicographical Numbers
  8. Sql中的union和union all的讲解
  9. oracle 存储过程编辑 卡死
  10. 达内TTS6.0课件oop_day02
  11. Xcode插件失效以后的处理方法
  12. ASP.net core 2.0.0 中 asp.net identity 2.0.0 的基本使用(三)—用户账户及cookie配置
  13. 论文笔记--PCN:Real-Time Rotation-Invariant Face Detection with Progressive Calibration Networks
  14. Do a web framework ourselves
  15. Nginx 如何设置反向代理 多服务器,配置区分开来,单独文件保存单个服务器 server 主机名配置,通过 include 实现
  16. CF747F Igor and Interesting Numbers
  17. _itemmod_extra_equipments_enable
  18. 关于scp在zsh报错:zsh:no matches found :
  19. Android 应用架构 - Google 推荐
  20. oracle查询锁表

热门文章

  1. 【javascript】slice()、substring()和substr() 三种字符串截取方法区别
  2. 【Linux SPI】RFID RC522 设备驱动
  3. javaWeb学习一
  4. 06 RDD编程
  5. 如何利用fooview实现钉钉自动打卡
  6. .net core 3.1项目运行在Windows server 2012R2服务器上,Decimal类型小数点不见了,求解!32112.7958
  7. Bugku-不可破译的密码[wp]
  8. 自定义Ribbon负载均衡
  9. pychars的使用
  10. redis cluster 部署