import json import readConfig as readConfig from common import common_utils from common.LogUtil import LogUtil from common.configHttp import ConfigHttp localReadConfig = readConfig.ReadConfig() localConfigHttp = ConfigHttp() localLogin_xls = common_utils.get_xls("userCase.xlsx", "login") # login def loginBiz(): """ login :return: token """ # set url url = common_utils.get_url_from_xml('login') localConfigHttp.set_url(url) config = readConfig.ReadConfig() config.set_headers("token", '') config.set_headers("secret", '') # set params account = localLogin_xls[4][3] password = localLogin_xls[4][4] data = {"account": account, "password": password, "source": "app"} localConfigHttp.set_data(data) LogUtil.info("step2:设置参数==>" + json.dumps(data, ensure_ascii=False))
import os import unittest import paramunittest import readConfig as readConfig from common import configHttp, common_utils from common import businessCommon from common.LogUtil import MyLog localUploadImg_xls = common_utils.get_xls("userCase.xlsx", "uploadImg") localReadConfig = readConfig.ReadConfig() localConfigHttp = configHttp.ConfigHttp() @paramunittest.parametrized(*localUploadImg_xls) class UploadImg(unittest.TestCase): def setParameters(self, case_name, method, token, whole, file, result, code, msg): """ set param :param case_name: :param method: :param token: :param whole: :param file: :param result: :param code: :param msg: :return: """ self.case_name = str(case_name) self.method = str(method)
import unittest import paramunittest import readConfig as readConfig from common import common_utils, configHttp from common.LogUtil import MyLog productInfo_xls = common_utils.get_xls("roomCase.xlsx", "getMyRoom") localReadConfig = readConfig.ReadConfig() localConfigHttp = configHttp.ConfigHttp() @paramunittest.parametrized(*productInfo_xls) class ProductInfo(unittest.TestCase): def setParameters(self, case_name, method, token, goods_id, result, code, msg): """ set params :param case_name: :param method: :param token: :param goods_id: :param result: :param code: :param msg: :return: """ self.case_name = str(case_name) self.method = str(method) self.token = str(token) self.goodsId = str(goods_id) self.result = str(result)
import unittest import paramunittest import common import readConfig as ReadConfig from common import configHttp, common_utils from common import businessCommon from common.LogUtil import MyLog localReadConfig = ReadConfig.ReadConfig() localConfigHttp = configHttp.ConfigHttp() localLogout_xls = common_utils.get_xls("userCase.xlsx", "logout") @paramunittest.parametrized(*localLogout_xls) class Logout(unittest.TestCase): def setParameters(self, case_name, method, token, result, code, msg): """ set parameters :param case_name: :param method: :param token: :param result: :param code: :param msg: :return: """ self.case_name = str(case_name) self.method = str(method) self.token = str(token)