Beispiel #1
0
 def setUpClass(self):
     self.runmethodhandle = RunMain.RunMethod()
     self.disposeapihandle = DisposeApi.DisposeApi(case_name)
     self.disposeheaderhandle = DisposeHeader.DisposeHeader()
     self.disposecasehandle = DisposeCase.DisposeCase(case_name)
     self.disposereporthandle = DisposeReport.DisposeReport(case_name)
     self.disposerelyhandle = DisposeRely.DisposeRely()
     self.disposeasserthandle = DisposeAssert.DisposeAssert()
     self.disposeenvhandle = DisposeEnv.DisposeEnv()
    def __init__(self):
        self.readenvjsonhandle = ReadJson.ReadJson('Env', 'ENV')
        self.readrelyjsonhandle = ReadJson.ReadJson('RelyOn', 'RELYON')
        self.readredishandle = ReadRedis.ReadRedis()
        self.readdbhandle = ReadDB.ReadDB()

        self.readconfighandle = ReadConfig.ReadConfig()
        self.version = self.readconfighandle.get_data('INTERFACE',
                                                      'version_num')

        self.formatconversionhandle = FormatConversion.FormatConversion()
        self.runmethodhandle = RunMain.RunMethod()
    def setUpClass(self):
        self.runmethodhandle = RunMain.RunMethod()
        self.disposeapihandle = DisposeApi.DisposeApi(case_name)
        self.disposeheaderhandle = DisposeHeader.DisposeHeader()
        self.disposecasehandle = DisposeCase.DisposeCase(case_name)
        self.disposereporthandle = DisposeReport.DisposeReport(case_name)
        self.disposerelyhandle = DisposeRely.DisposeRely()
        self.readdbhandle = ReadDB.ReadDB()
        self.readtxthandle = ReadTxt.ReadTxt('cleardata')

        #清除测试数据
        sql = self.readtxthandle.get_clear_data()
        print('-------------------开始清除原测试数据-------------------')
        self.readdbhandle.modify_data(sql)
        print('-------------------结束清除原测试数据-------------------')
        print('--------------------开始创建测试数据--------------------')
Beispiel #4
0
 def checkResult(self):  # 断言
     """
     check test result
     :return:
     """
     url1 = "http://www.xxx.com/login?"
     new_url = url1 + self.query
     data1 = dict(
         urllib.parse.parse_qsl(urllib.parse.urlsplit(new_url).query)
     )  # 将一个完整的URL中的name=&pwd=转换为{'name':'xxx','pwd':'bbb'}
     info = RunMain().run_main(
         self.method, url,
         data1)  # 根据Excel中的method调用run_main来进行requests请求,并拿到响应
     ss = json.loads(info)  # 将响应转换为字典格式
     if self.case_name == 'login':  # 如果case_name是login,说明合法,返回的code应该为200
         self.assertEqual(ss['code'], 200)
     if self.case_name == 'login_error':  # 同上
         self.assertEqual(ss['code'], -1)
     if self.case_name == 'login_null':  # 同上
         self.assertEqual(ss['code'], 10001)