Esempio n. 1
0
 def test_01(self,case):
     '''不同的参数导致不同的结果'''
     self.row = case.case_id + 1
     # res = reg(*eval(case.data))
     try:
         pass
         # self.assertEqual(eval(case.expected),res)
     except AssertionError as e:
         res = '失败'
         my_log.error(e)
         raise e
     else:
         res = 'pass'
         my_log.info('测试结果:{}'.format(res))
     finally:
         # 在excel表格中的第四列写入数据
         wb.write_data(row=self.row, column=4, msg=res)
    def request(self,
                method,
                url,
                params=None,
                data=None,
                headers=None,
                cookies=None,
                json=None):

        method = method.lower()
        if method == "post":
            # 判断是否使用json来传参(适用于接口项目有使用json传参)
            if json:
                my_log.info("正在发送请求,请求地址:{}, 请求参数:{}".format(url, json))
                return self.session.post(url=url,
                                         json=json,
                                         headers=headers,
                                         cookies=cookies)
            else:
                my_log.info("正在发送请求,请求地址:{}, 请求参数:{}".format(url, data))
                return self.session.post(url=url,
                                         data=data,
                                         headers=headers,
                                         cookies=cookies)
        elif method == "get":
            my_log.info("正在发送请求,请求地址:{}, 请求参数:{}".format(url, params))
            return self.session.get(url=url,
                                    params=params,
                                    headers=headers,
                                    cookies=cookies)
 def tearDownClass(cls):
     my_log.info(
         "============================== 取现接口测试执行完毕 =============================="
     )
     cls.request.close()
     cls.db.close()
 def setUpClass(cls):
     my_log.info(
         "============================== 准备开始执行取现接口的测试 =============================="
     )
     cls.request = HTTPRequest2()
     cls.db = ExecuteMysql()