From aa12cd69f9e2872b0eea693774fa40e532c9759c Mon Sep 17 00:00:00 2001 From: zy7y <7631909+zy7y@user.noreply.gitee.com> Date: Mon, 14 Sep 2020 17:09:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DSeesion/Cookie=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E4=B8=AD=E6=97=A0=E6=B3=95=E5=85=B3=E8=81=94=E7=9A=84?= =?UTF-8?q?bug=20=E4=B9=8B=E5=89=8D=E6=98=AF=E5=9C=A8=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E4=B8=AD=E5=AE=9E=E4=BE=8B=E7=9A=84Session?= =?UTF-8?q?=EF=BC=8C=E5=AF=BC=E8=87=B4=E6=AF=8F=E6=89=A7=E8=A1=8C=E6=9F=90?= =?UTF-8?q?=E4=B8=AA=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95=E6=97=B6=E9=83=BD?= =?UTF-8?q?=E4=BC=9A=E7=94=9F=E6=88=90=E6=96=B0=E7=9A=84Seesion=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=EF=BC=8C=E6=97=A0=E6=B3=95=E5=AE=9E=E7=8E=B0cookie?= =?UTF-8?q?=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/base_requests.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/base_requests.py b/api/base_requests.py index 91b774d..dab6c4e 100644 --- a/api/base_requests.py +++ b/api/base_requests.py @@ -13,7 +13,9 @@ import requests class BaseRequest(object): def __init__(self): - pass + # 修改时间:2020年9月14日17:09 + # 确保,整个接口测试中,使用同一个requests.Session() 来管理cookie + self.session = requests.Session() # 请求 def base_requests(self, method, url, parametric_key=None, data=None, file_var=None, file_path=None, header=None): @@ -31,7 +33,8 @@ class BaseRequest(object): :param header: 请求头 :return: 返回json格式的响应 """ - session = requests.Session() + # 修改时间:2020年9月14日17:09 + session = self.session if (file_var in [None, '']) and (file_path in [None, '']): files = None else: