import unittest,requests标签:封装,请求,url,res,params,data,method From: https://www.cnblogs.com/mayueyue/p/17587820.html
import yaml
from common.mylogger import logger
class Basecase(unittest.TestCase):
def request_token(self):
pass
def request(self,method,url,params=None,data=None,json=None,**args):
method=method.upper()
if method=="GET":
res=requests.get(url=url,params=params,**args)
logger.info(f"请求方式:{method},请求URL:{url},请求参数:{params},返回参数:{res.text}")
return res
elif method == "POST":
res=requests.post(url=url,data=data,json=json,**args)
logger.info(f"请求方式:{method},请求URL:{url},请求参数:{data},返回参数:{res.text}")
return res