首页 > Web开发 > 详细

pytest-html报告中,添加描述

时间:2020-06-29 09:03:20      阅读:423      评论:0      收藏:0      [点我收藏+]

 

 

在conftest.py中实现

@pytest.mark.optionalhook
def pytest_html_results_summary(prefix, summary, postfix):
prefix.extend([html.p("测试人: 电商测试组")])

@pytest.mark.optionalhook
def pytest_html_results_table_header(cells):
cells.insert(1, html.th(‘Description‘))
cells.insert(2, html.th(‘Test‘)) #增加一列,解决用例参数入参为中文时正常显示
cells.pop(3) #将原有的test删除

@pytest.mark.optionalhook
def pytest_html_results_table_row(report, cells):
cells.insert(1, html.td(report.description))
cells.insert(2, html.td(report.nodeid))
cells.pop(3)


@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()
report.description = str(item.function.__doc__)
report.nodeid = report.nodeid.encode("utf-8").decode("unicode_escape") # 设置编码显示中文

 

pytest-html报告中,添加描述

原文:https://www.cnblogs.com/jodie2019/p/13205709.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!