# coding:utf-8 import json import unittest import requests import paramunittest from interfaceTest.common import common from interfaceTest.common import businessCommon from interfaceTest.common.Log import MyLog import interfaceTest.readConfig as readConfig from interfaceTest.common import configHttp as configHttp one_xls = common.get_xls("data.xls", "one") localReadConfig = readConfig.ReadConfig() localConfigHttp = configHttp.ConfigHttp() #print update_xls[0][3] @paramunittest.parametrized(*one_xls) class jobone(unittest.TestCase): def setParameters(self, case_name, method, token, param, result, stat, msg): self.case_name = str(case_name) self.method = str(method) self.token = str(token) self.param = str(param) self.result = str(result) self.stat = str(stat) self.msg = msg self.response = None self.info = None self.logintoken = None
import pymysql from interfaceTest import readConfig from interfaceTest.common.Log import MyLog as Log locakReadConfig = readConfig.ReadConfig() class MyDB: global host, username, password, port, database, config host = locakReadConfig.get_db("host") username = locakReadConfig.get_db("username") password = locakReadConfig.get_db("password") port = locakReadConfig.get_db("port") database = locakReadConfig.get_db("database") config = { 'host': str(host), 'user': username, 'password': password, 'port': int(port), 'db': database } def __init__(self): self.log = Log.get_log() self.logger = self.log.get_loger() self.db = None self.cursor = None def connectDb(self): try:
from interfaceTest import readConfig readconfig = readConfig.ReadConfig() class geturlParams(): # 定义一个方法,将从配置文件中读取的进行拼接 def get_Url(self): # new_url = readconfig.get_http('scheme') + '://' + readconfig.get_http('baseurl') + ':' + readconfig.get_http('port') + '/login' + '?' new_url = readconfig.get_http('scheme') + '://' + readconfig.get_http( 'baseurl') + ':' + readconfig.get_http('port') #logger.info('new_url'+new_url) return new_url if __name__ == '__main__': # 验证拼接后的正确性 print(geturlParams().get_Url())
import os import unittest from interfaceTest import getpathInfo from interfaceTest import readConfig from interfaceTest.common import HTMLTestRunner from interfaceTest.common.configEmail import SendEmail send_mail = SendEmail() path = getpathInfo.get_Path() report_path = os.path.join(path, 'result') on_off = readConfig.ReadConfig().get_email('on_off') class AllTest: # 定义一个类AllTest def __init__(self): # 初始化一些参数和数据 global resultPath resultPath = os.path.join(report_path, "report.html") # result/report.html self.caseListFile = os.path.join(path, "caselist.txt") # 配置执行哪些测试文件的配置文件路径 self.caseFile = os.path.join(path, "testCase") # 真正的测试断言文件路径 self.caseList = [] def set_case_list(self): """ 读取caselist.txt文件中的用例名称,并添加到caselist元素组 :return: """ fb = open(self.caseListFile, encoding='utf-8') for value in fb.readlines(): data = str(value)