#coding:utf-8
from base.operation_excel import OperationExcel
from base.operation_json import OperetionJson
class global_var:
#case_id
Id = ‘0‘
#测试用例名称
request_name = ‘1‘
#接口测试url
url = ‘2‘
#执行结果
result = ‘5‘
#是否执行
run = ‘3‘
#测试数据的json文件
data = ‘4‘
class GetData:
def __init__(self):
self.opera_excel = OperationExcel()
#获取caseid判断是否执行
def get_is_run(self,case_id):
flag = None
col = int(global_var.run)
row = OperationExcel().get_row_num(case_id)
run_model = self.opera_excel.get_cell_value(row,col)
if run_model == ‘yes‘:
flag = True
else:
flag = False
return flag
#获取url
def get_request_url(self,row):
col = int(global_var.url)
url = self.opera_excel.get_cell_value(row,col)
return url
#获取请求数据
def get_request_data(self,row):
col = int(global_var.data)
data = self.opera_excel.get_cell_value(row,col)
if data == ‘‘:
return None
return data
#通过获取关键字拿到data数据
def get_data_for_json(self,row):
opera_json = OperetionJson()
request_data = opera_json.get_data(self.get_request_data(row))
return request_data
#写入执行结果
def write_result(self,row,value):
col = int(global_var.result)
self.opera_excel.write_value(row,col,value)
if __name__ == ‘__main__‘:
t=GetData()
t.write_result(1,‘pass‘)
原文:https://www.cnblogs.com/macrolai/p/13735496.html