def test_raises_error_with_any_other_requests_exception(self, mock):
exceptions = [
requests.exceptions.HTTPError,
requests.exceptions.ConnectionError,
requests.exceptions.ProxyError,
requests.exceptions.SSLError,
requests.exceptions.Timeout,
requests.exceptions.ConnectTimeout,
requests.exceptions.ReadTimeout,
requests.exceptions.URLRequired,
requests.exceptions.TooManyRedirects,
requests.exceptions.MissingSchema,
requests.exceptions.InvalidSchema,
requests.exceptions.InvalidURL,
requests.exceptions.InvalidHeader,
requests.exceptions.ChunkedEncodingError,
requests.exceptions.ContentDecodingError,
requests.exceptions.StreamConsumedError,
requests.exceptions.RetryError,
requests.exceptions.UnrewindableBodyError,
]
mock.side_effect = exceptions
for _ in exceptions:
with self.assertRaises(HTTPError):
request('GET', 'foo')
评论列表
文章目录