首页 > 其他 > 详细

接口自动化架构-2

时间:2019-06-14 13:01:51      阅读:112      评论:0      收藏:0      [点我收藏+]

获取测试用例

import xlrd

from lib.log import atp_log
class OpCase(object):
    def get_case(self,file_path):
        case = []
        if file_path.endswith(.xls) or file_path.endswith(.xlsx):
            try:
                book = xlrd.open_workbook(file_path)
                sheet = book.sheet_by_index(0)
                for i in range(1, sheet.nrows):  # excle中一共有多少行
                    row_data = sheet.row_values(i)  # 获取每行的值
                    case.append(row_data[4:8])  # 切片(因为只需要取下标4到下标7的值)
                atp_log.info(共读取%s条用例 % (len(case)))
            except Exception as e:
                atp_log.error(%s用例获取失败,错误信息%s % (file_path, e))
        else:
            atp_log.error(用例文件不合法:%s % file_path)
        return case

#测试
#m = OpCase()
#m.get_case(r‘E:\Users\admin\PycharmProjects\Interface test\ATP‘)
#m.get_case(‘xx.xls‘)
#m.get_case(r‘E:\Users\admin\PycharmProjects\Interface test\ATP\cases\测试用例.xlsx‘)

发送请求

    def my_request(self,url,method,data):
        method = method.upper()
        if method==POST:
            requests.get(url,params=data)
        else:
            atp_log.warning(该请求方式暂不支持)

 

接口自动化架构-2

原文:https://www.cnblogs.com/ruijie/p/11022439.html

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