首页 > 其他 > 详细

接口测试框架

时间:2021-08-20 21:15:59      阅读:15      评论:0      收藏:0      [点我收藏+]

Requests库+Pytest单元测试框架+Pytest_html报告+SqlSever数据库

1、pytest-html

使用测试函数docstring添加描述列,添加可排序的时间列,并删除links列

from datetime import datetime
from py.xml import html
import pytest


def pytest_html_results_table_header(cells):
    cells.insert(2, html.th("Description"))
    cells.insert(1, html.th("Time", class_="sortable time", col="time"))
    cells.pop()


def pytest_html_results_table_row(report, cells):
    cells.insert(2, html.td(report.description))
    cells.insert(1, html.td(datetime.utcnow(), class_="col-time"))
    cells.pop()


@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
    outcome = yield
    report = outcome.get_result()
    report.description = str(item.function.__doc__)

 

接口测试框架

原文:https://www.cnblogs.com/gocean/p/15166168.html

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