# _*_ coding:utf-8 _*_ import unittest, paramunittest, json from Common import configHttp, readExcel, readConfig, getheader, getrandom, log excel = readExcel.readExcel('API_TestCase.xlsx') #获取excel文件 names = excel.get_sheetnames() #获取sheel testcase = excel.get_xlsx(names[2]) #获取指定shell的case baseurl = readConfig.Read_Config().get_info('HTTP', 'baseurl') #获取配置文件的baseurl headers = getheader.host_headers() #获取heders log_info = log.logger #导入log系统 @paramunittest.parametrized(*testcase) class testUserLogin(unittest.TestCase): def setParameters(self, NO, case_name, method, path, data, code): """ 从 excel 中获取用例 :param NO: 用例序号 :param case_name: 用例名称 :param method: HTTP方法 :param path: 路径 :param data: 参数 :param code: 响应 """ self.case_name = NO self.case_name = str(case_name) self.method = str(method) self.path = baseurl + str(path) self.data = json.loads(data) self.code = int(code) #字符串转字典类型
@E-mail:[email protected] @Time:2020/9/3 11:28 下午 @Author:Nobita @Version:1.0 @Desciption:/headers接口的测试用例及断言 """ import json import unittest import paramunittest from Common import readExcel, geturlParams from Common.Assert import Assertions from Common.Request import RunMain url = geturlParams.geturlParams().get_Url() # 调用我们的geturlParams获取我们拼接的URL login_xls = readExcel.readExcel().get_xls('learning-API-test_Case.xlsx', 'header') @paramunittest.parametrized(*login_xls) class test_learning_API(unittest.TestCase): def setParameters(self, case_name, path, headers, data, method): """ set params :param case_name: :param path :param headers :param data :param method :return: """ self.case_name = case_name