python做接口自动化测试,测试的接口是查询内容的,get请求发送响应成功,但是没有做过滤,返回的总数不对,应该返回1条数据的,但是返回了四条数据,我猜测应该是没有过滤,希望大伙帮忙看看,感谢
(http://localhostxxx/?start=1&filter=subCaseNo%20in%20%5B%272304190004-1%27%5D%EF%BC%89%EF%BC%8C
def sendGetByProxy(url, proxies, cookie, paramDict):
'''
:param url:
:param proxies: proxies = {'http': 'http://localhost:8888', 'https': 'http://localhost:8888'}
:param cookie:
:param paramDict:
:return:
'''
s = requests.Session()
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
headers = {
'user-agent': UserAgent(verify_ssl=False).random,
'Connection': 'close' ###释放keep_live
}
if cookie != None:
headers['Cookie'] = cookie
if paramDict:
headers.update(paramDict)
#######重试
s.mount('http://', HTTPAdapter(max_retries=3))
s.mount('https://', HTTPAdapter(max_retries=3))
if proxies:
try:
####设置超时 timeout=5 allow_redirects=False 取消跳转
data = s.get(url, headers=headers, proxies=proxies, verify=False, allow_redirects=False, timeout=10)
# requests.adapters.DEFAULT_RETRIES = 5 ####重试次数
s.keep_alive = False ####关闭不必要的链接
except Exception as e:
print('访问:',url,e)
data = self.cycle(s,headers, url)
return data
else:
try:
data = s.get(url, headers=headers, verify=False)
requests.adapters.DEFAULT_RETRIES = 5
s.keep_alive = False
except Exception as e:
print(e)
return None
print(data)
return data