unittest requests 在添加了以下代码依然出现以下错误:
1 import urllib3 2 urllib3.disable_warnings()
InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised.
See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings InsecureRequestWarning,
解决办法:
在 def setUp(self): 添加以下 红色代码即可
1 def setUp(self): 2 3 # 解决错误 ResourceWarning: Enable tracemalloc to get the object allocation traceback 4 warnings.simplefilter(‘ignore‘,ResourceWarning) 5 self.s = requests.session() 6 self.s.verify= False 7 # 解决 InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. 8 requests.packages.urllib3.disable_warnings()