当我尝试使用以下方法发出请求时:
request_arguments = {
"method": method,
"url": self._build_url(self.url, action),
"headers": self._get_headers(**kwargs),
"data": kwargs["data"] if "data" in kwargs else {},
"verify": False
}
response = requests.request(**request_arguments)
我收到以下警告:
tests/end_to_end/test_integration_alert.py::test_mm_put
/anaconda3/lib/python3.6/site-packages/urllib3/connectionpool.py:858:
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)
我试图通过以下方式在构造函数中隐藏它:
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
如此处所述:
Suppress InsecureRequestWarning: Unverified HTTPS request is being made in Python2.6
有趣的是,我仍然在第一次调用该代码时得到警告,但是随后的调用被正确地抑制了。 (我以正确的顺序击中了断点)
我如何也可以抑制初始警告?