本文整理匯總了Python中http.HTTPStatus.HTTP_VERSION_NOT_SUPPORTED屬性的典型用法代碼示例。如果您正苦於以下問題:Python HTTPStatus.HTTP_VERSION_NOT_SUPPORTED屬性的具體用法?Python HTTPStatus.HTTP_VERSION_NOT_SUPPORTED怎麽用?Python HTTPStatus.HTTP_VERSION_NOT_SUPPORTED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類http.HTTPStatus
的用法示例。
在下文中一共展示了HTTPStatus.HTTP_VERSION_NOT_SUPPORTED屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_version_invalid
# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import HTTP_VERSION_NOT_SUPPORTED [as 別名]
def test_version_invalid(self):
self.con._http_vsn = 99
self.con._http_vsn_str = 'HTTP/9.9'
self.con.putrequest('GET', '/')
self.con.endheaders()
res = self.con.getresponse()
self.assertEqual(res.status, HTTPStatus.HTTP_VERSION_NOT_SUPPORTED)
示例2: test_http_status_to_canonical_code
# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import HTTP_VERSION_NOT_SUPPORTED [as 別名]
def test_http_status_to_canonical_code(self):
for status_code, expected in (
(HTTPStatus.OK, StatusCanonicalCode.OK),
(HTTPStatus.ACCEPTED, StatusCanonicalCode.OK),
(HTTPStatus.IM_USED, StatusCanonicalCode.OK),
(HTTPStatus.MULTIPLE_CHOICES, StatusCanonicalCode.OK),
(HTTPStatus.BAD_REQUEST, StatusCanonicalCode.INVALID_ARGUMENT),
(HTTPStatus.UNAUTHORIZED, StatusCanonicalCode.UNAUTHENTICATED),
(HTTPStatus.FORBIDDEN, StatusCanonicalCode.PERMISSION_DENIED),
(HTTPStatus.NOT_FOUND, StatusCanonicalCode.NOT_FOUND),
(
HTTPStatus.UNPROCESSABLE_ENTITY,
StatusCanonicalCode.INVALID_ARGUMENT,
),
(
HTTPStatus.TOO_MANY_REQUESTS,
StatusCanonicalCode.RESOURCE_EXHAUSTED,
),
(HTTPStatus.NOT_IMPLEMENTED, StatusCanonicalCode.UNIMPLEMENTED),
(HTTPStatus.SERVICE_UNAVAILABLE, StatusCanonicalCode.UNAVAILABLE),
(
HTTPStatus.GATEWAY_TIMEOUT,
StatusCanonicalCode.DEADLINE_EXCEEDED,
),
(
HTTPStatus.HTTP_VERSION_NOT_SUPPORTED,
StatusCanonicalCode.INTERNAL,
),
(600, StatusCanonicalCode.UNKNOWN),
(99, StatusCanonicalCode.UNKNOWN),
):
with self.subTest(status_code=status_code):
actual = http_status_to_canonical_code(int(status_code))
self.assertEqual(actual, expected, status_code)