def request(self): if self.method.upper() == 'GET': ''' 发送get 请求 :return: 响应对象 ''' try: response = requests.get(url=self.url, params=self.params, headers=self.headers, timeout=float(self.timeout)) return response except TimeoutError: MyLog.get_log().error("timeout") pass elif self.method.upper() == 'POST': ''' 发送post请求 :return: ''' try: response = requests.post(self.url, data=self.data, headers=self.headers, timeout=float(self.timeout)) return response except TimeoutError: MyLog.get_log().error("timeout") pass elif self.method.upper() == 'POSTWITHJSON': try: response = requests.post(self.url, headers=self.headers, json=self.data, timeout=float(self.timeout)) return response except TimeoutError: MyLog.get_log().error("Time out!") pass elif self.method.upper() == 'POSTWITHFILE': try: response = requests.post(self.url, headers=self.headers, data=self.data, timeout=float(self.timeout), files=self.files, cookies=self.cookies) # MyLog.get_log().debug("文件上传 " + response.request.body) return response except TimeoutError: MyLog.get_log().error("Time out!") pass return response
def run(self): try: suit = self.set_case_suite() if suit is not None: MyLog.get_log().info( "-------------------------测试开始-----------------------") report_path = os.path.abspath( os.path.join(os.path.dirname(__file__), "report", "report.html")) fp = open(report_path, 'wb') runner = HTMLTestRunner.HTMLTestRunner( stream=fp, title='Interface Test Report', description='jjj') runner.run(suit) # 套件,为测试用例的有序集合 fp.close() else: pass except Exception as ex: MyLog.get_log().error(str(ex)) finally: MyLog.get_log().info( "-------------------------测试结束-----------------------")
def setUp(self) -> None: self.mylog = MyLog.get_log()
def setUp(self) -> None: self.dal = TestApiSpecialad() self.log = MyLog.get_log()
def setUp(self) -> None: self.dal = TestApiStatistics() self.mylog = MyLog.get_log()
def setUp(self) -> None: self.mylog = MyLog.get_log() self.dal = TestApiSubmitOrdergoodsComment()
def setUp(self) -> None: # self.dal = TestApiSpecialcms() 导入后直接用类属性 self.mylog = MyLog.get_log()