获取测试用例 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
获取测试用例
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(‘该请求方式暂不支持‘)