def setUpClass(cls): with open('{}'.format( os.path.join(os.path.dirname(os.getcwd()), 'Config') + '\conf.yaml'), 'r', encoding="utf-8") as r: config = yaml.load(r) # 解析并读写yaml文件 cls.app_host = config['cms_host'] cls.cms_headers = eval(config['cms_headers']) cls.session = cms_cookies() cls.cms_headers['Authorization'] = get_yaml_variable('Authorization') cls.stationName = "野风时代" + str(random.randint(1, 1000)) cls.spot_code = random.randint(100000, 999999) return cls.cms_headers
def setUpClass(cls): Log().info("正在执行:登陆测试") dealer_Session() #登陆写入session # token=get_yaml_variable("X-SessionToken-With") # print("登陆后的token为:%s"%token) cls.app_host = cls.app_host cls.cms_host = cls.cms_host cls.Dealer_session = { "X-SessionToken-With": get_yaml_variable("X-SessionToken-With") } cls.app_headers.update(cls.Dealer_session) cls.session = cms_cookies() #将获取的cookie设置为session变量全局使用
def write_result(response,write_excelPath,sheet_id): # 返回结果的行数row_nub if response !="": row_nub = response['rowNum']-1 #引入写入的方法 但前提是要读取数据 # data.write_value(row_nub, 10,333333) # table=UtilExcel(excelPath=filename, sheet_id=sheet_id) # table.write_value(row_nub,9,response["Response"]) # table.write_value(row_nub, 10, response["Result"]) #这样只能写入一个 变量赋值原因 UtilExcel(excelPath=write_excelPath, sheet_id=sheet_id).write_value(row_nub,9,response["Response"]) # 状态码非200时的返回信息 UtilExcel(excelPath=write_excelPath, sheet_id=sheet_id).write_value(row_nub, 10, response["Result"]) # 写入测试结果 UtilExcel(excelPath=write_excelPath, sheet_id=sheet_id).write_value(row_nub, 11, response["Times"]) #写入接口执行时间 UtilExcel(excelPath=write_excelPath, sheet_id=sheet_id).write_value(row_nub, 12, response['Msg']) # 抛异常 else: # print('111') pass # if __name__ == "__main__": excelPath = "E:\chemofang\Config\cms_api.xlsx" sheet_id = 0 read_data = UtilExcel(excelPath,sheet_id).dict_data() # print(read_data[0]) session= cms_cookies() Response = send_requests(session, read_data[5]) # print(response) # print(Response["Response"]) write_result(Response, write_excelPath=excelPath,sheet_id=sheet_id)
def setUpClass(cls): Log().info("正在执行:GPS管理模块测试") cls.cms_host = cls.cms_host cls.session = cms_cookies() # 将获取的cookie设置为session变量全局使用
def setUpClass(cls): cls.session = cms_cookies() # 一次性登陆
def setUpClass(cls): Log().info("正在执行:登陆测试") # token=get_yaml_variable("X-SessionToken-With") # print("登陆后的token为:%s"%token) cls.cms_host = cls.cms_host cls.session = cms_cookies() # 将获取的cookie设置为session变量全局使用