接口自动化架构-获取用例

获取测试用例

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('该请求方式暂不支持')

 

转载于:https://www.cnblogs.com/ruijie/p/11022439.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值