接口测试框架------关联excel与json文件获取请求参数

import json
from utils.public import *
from utils.operationExcel import OperationExcel
class OperationJson:
def __init__(self):
self.excel = OperationExcel()
def getReadJson(self):
'''打开json文件'''
with open(data_dir(filename='requestData.json'),encoding='utf-8') as fp:
#读取json文件中的内容
data = json.load(fp)
return data
def get_json_data(self,row):
'''通过key值获得value'''
return self.getReadJson()[self.excel.get_request_data(row=row)]
opert = OperationJson()
print(opert.get_json_data(1))

浙公网安备 33010602011771号