diff --git a/falcon/status_codes.py b/falcon/status_codes.py index 64fa8d806..04d618dfc 100644 --- a/falcon/status_codes.py +++ b/falcon/status_codes.py @@ -18,127 +18,127 @@ # 1xx - Informational HTTP_100: Final[str] = '100 Continue' -HTTP_CONTINUE = HTTP_100 +HTTP_CONTINUE: Final[str] = HTTP_100 HTTP_101: Final[str] = '101 Switching Protocols' -HTTP_SWITCHING_PROTOCOLS = HTTP_101 +HTTP_SWITCHING_PROTOCOLS: Final[str] = HTTP_101 HTTP_102: Final[str] = '102 Processing' -HTTP_PROCESSING = HTTP_102 +HTTP_PROCESSING: Final[str] = HTTP_102 # 2xx - Success HTTP_200: Final[str] = '200 OK' -HTTP_OK = HTTP_200 +HTTP_OK: Final[str] = HTTP_200 HTTP_201: Final[str] = '201 Created' -HTTP_CREATED = HTTP_201 +HTTP_CREATED: Final[str] = HTTP_201 HTTP_202: Final[str] = '202 Accepted' -HTTP_ACCEPTED = HTTP_202 +HTTP_ACCEPTED: Final[str] = HTTP_202 HTTP_203: Final[str] = '203 Non-Authoritative Information' -HTTP_NON_AUTHORITATIVE_INFORMATION = HTTP_203 +HTTP_NON_AUTHORITATIVE_INFORMATION: Final[str] = HTTP_203 HTTP_204: Final[str] = '204 No Content' -HTTP_NO_CONTENT = HTTP_204 +HTTP_NO_CONTENT: Final[str] = HTTP_204 HTTP_205: Final[str] = '205 Reset Content' -HTTP_RESET_CONTENT = HTTP_205 +HTTP_RESET_CONTENT: Final[str] = HTTP_205 HTTP_206: Final[str] = '206 Partial Content' -HTTP_PARTIAL_CONTENT = HTTP_206 +HTTP_PARTIAL_CONTENT: Final[str] = HTTP_206 HTTP_207: Final[str] = '207 Multi-Status' -HTTP_MULTI_STATUS = HTTP_207 +HTTP_MULTI_STATUS: Final[str] = HTTP_207 HTTP_208: Final[str] = '208 Already Reported' -HTTP_ALREADY_REPORTED = HTTP_208 +HTTP_ALREADY_REPORTED: Final[str] = HTTP_208 HTTP_226: Final[str] = '226 IM Used' -HTTP_IM_USED = HTTP_226 +HTTP_IM_USED: Final[str] = HTTP_226 # 3xx - Redirection HTTP_300: Final[str] = '300 Multiple Choices' -HTTP_MULTIPLE_CHOICES = HTTP_300 +HTTP_MULTIPLE_CHOICES: Final[str] = HTTP_300 HTTP_301: Final[str] = '301 Moved Permanently' -HTTP_MOVED_PERMANENTLY = HTTP_301 +HTTP_MOVED_PERMANENTLY: Final[str] = HTTP_301 HTTP_302: Final[str] = '302 Found' -HTTP_FOUND = HTTP_302 +HTTP_FOUND: Final[str] = HTTP_302 HTTP_303: Final[str] = '303 See Other' -HTTP_SEE_OTHER = HTTP_303 +HTTP_SEE_OTHER: Final[str] = HTTP_303 HTTP_304: Final[str] = '304 Not Modified' -HTTP_NOT_MODIFIED = HTTP_304 +HTTP_NOT_MODIFIED: Final[str] = HTTP_304 HTTP_305: Final[str] = '305 Use Proxy' -HTTP_USE_PROXY = HTTP_305 +HTTP_USE_PROXY: Final[str] = HTTP_305 HTTP_307: Final[str] = '307 Temporary Redirect' -HTTP_TEMPORARY_REDIRECT = HTTP_307 +HTTP_TEMPORARY_REDIRECT: Final[str] = HTTP_307 HTTP_308: Final[str] = '308 Permanent Redirect' -HTTP_PERMANENT_REDIRECT = HTTP_308 +HTTP_PERMANENT_REDIRECT: Final[str] = HTTP_308 # 4xx - Client Error HTTP_400: Final[str] = '400 Bad Request' -HTTP_BAD_REQUEST = HTTP_400 +HTTP_BAD_REQUEST: Final[str] = HTTP_400 HTTP_401: Final[str] = '401 Unauthorized' # <-- Really means "unauthenticated" -HTTP_UNAUTHORIZED = HTTP_401 +HTTP_UNAUTHORIZED: Final[str] = HTTP_401 HTTP_402: Final[str] = '402 Payment Required' -HTTP_PAYMENT_REQUIRED = HTTP_402 +HTTP_PAYMENT_REQUIRED: Final[str] = HTTP_402 HTTP_403: Final[str] = '403 Forbidden' # <-- Really means "unauthorized" -HTTP_FORBIDDEN = HTTP_403 +HTTP_FORBIDDEN: Final[str] = HTTP_403 HTTP_404: Final[str] = '404 Not Found' -HTTP_NOT_FOUND = HTTP_404 +HTTP_NOT_FOUND: Final[str] = HTTP_404 HTTP_405: Final[str] = '405 Method Not Allowed' -HTTP_METHOD_NOT_ALLOWED = HTTP_405 +HTTP_METHOD_NOT_ALLOWED: Final[str] = HTTP_405 HTTP_406: Final[str] = '406 Not Acceptable' -HTTP_NOT_ACCEPTABLE = HTTP_406 +HTTP_NOT_ACCEPTABLE: Final[str] = HTTP_406 HTTP_407: Final[str] = '407 Proxy Authentication Required' -HTTP_PROXY_AUTHENTICATION_REQUIRED = HTTP_407 +HTTP_PROXY_AUTHENTICATION_REQUIRED: Final[str] = HTTP_407 HTTP_408: Final[str] = '408 Request Timeout' -HTTP_REQUEST_TIMEOUT = HTTP_408 +HTTP_REQUEST_TIMEOUT: Final[str] = HTTP_408 HTTP_409: Final[str] = '409 Conflict' -HTTP_CONFLICT = HTTP_409 +HTTP_CONFLICT: Final[str] = HTTP_409 HTTP_410: Final[str] = '410 Gone' -HTTP_GONE = HTTP_410 +HTTP_GONE: Final[str] = HTTP_410 HTTP_411: Final[str] = '411 Length Required' -HTTP_LENGTH_REQUIRED = HTTP_411 +HTTP_LENGTH_REQUIRED: Final[str] = HTTP_411 HTTP_412: Final[str] = '412 Precondition Failed' -HTTP_PRECONDITION_FAILED = HTTP_412 +HTTP_PRECONDITION_FAILED: Final[str] = HTTP_412 HTTP_413: Final[str] = '413 Payload Too Large' -HTTP_REQUEST_ENTITY_TOO_LARGE = HTTP_413 +HTTP_REQUEST_ENTITY_TOO_LARGE: Final[str] = HTTP_413 HTTP_414: Final[str] = '414 URI Too Long' -HTTP_REQUEST_URI_TOO_LONG = HTTP_414 +HTTP_REQUEST_URI_TOO_LONG: Final[str] = HTTP_414 HTTP_415: Final[str] = '415 Unsupported Media Type' -HTTP_UNSUPPORTED_MEDIA_TYPE = HTTP_415 +HTTP_UNSUPPORTED_MEDIA_TYPE: Final[str] = HTTP_415 HTTP_416: Final[str] = '416 Range Not Satisfiable' -HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = HTTP_416 +HTTP_REQUESTED_RANGE_NOT_SATISFIABLE: Final[str] = HTTP_416 HTTP_417: Final[str] = '417 Expectation Failed' -HTTP_EXPECTATION_FAILED = HTTP_417 +HTTP_EXPECTATION_FAILED: Final[str] = HTTP_417 HTTP_418: Final[str] = "418 I'm a teapot" -HTTP_IM_A_TEAPOT = HTTP_418 +HTTP_IM_A_TEAPOT: Final[str] = HTTP_418 HTTP_422: Final[str] = '422 Unprocessable Entity' -HTTP_UNPROCESSABLE_ENTITY = HTTP_422 +HTTP_UNPROCESSABLE_ENTITY: Final[str] = HTTP_422 HTTP_423: Final[str] = '423 Locked' -HTTP_LOCKED = HTTP_423 +HTTP_LOCKED: Final[str] = HTTP_423 HTTP_424: Final[str] = '424 Failed Dependency' -HTTP_FAILED_DEPENDENCY = HTTP_424 +HTTP_FAILED_DEPENDENCY: Final[str] = HTTP_424 HTTP_426: Final[str] = '426 Upgrade Required' -HTTP_UPGRADE_REQUIRED = HTTP_426 +HTTP_UPGRADE_REQUIRED: Final[str] = HTTP_426 HTTP_428: Final[str] = '428 Precondition Required' -HTTP_PRECONDITION_REQUIRED = HTTP_428 +HTTP_PRECONDITION_REQUIRED: Final[str] = HTTP_428 HTTP_429: Final[str] = '429 Too Many Requests' -HTTP_TOO_MANY_REQUESTS = HTTP_429 +HTTP_TOO_MANY_REQUESTS: Final[str] = HTTP_429 HTTP_431: Final[str] = '431 Request Header Fields Too Large' -HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = HTTP_431 +HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE: Final[str] = HTTP_431 HTTP_451: Final[str] = '451 Unavailable For Legal Reasons' -HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = HTTP_451 +HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: Final[str] = HTTP_451 # 5xx - Server Error HTTP_500: Final[str] = '500 Internal Server Error' -HTTP_INTERNAL_SERVER_ERROR = HTTP_500 +HTTP_INTERNAL_SERVER_ERROR: Final[str] = HTTP_500 HTTP_501: Final[str] = '501 Not Implemented' -HTTP_NOT_IMPLEMENTED = HTTP_501 +HTTP_NOT_IMPLEMENTED: Final[str] = HTTP_501 HTTP_502: Final[str] = '502 Bad Gateway' -HTTP_BAD_GATEWAY = HTTP_502 +HTTP_BAD_GATEWAY: Final[str] = HTTP_502 HTTP_503: Final[str] = '503 Service Unavailable' -HTTP_SERVICE_UNAVAILABLE = HTTP_503 +HTTP_SERVICE_UNAVAILABLE: Final[str] = HTTP_503 HTTP_504: Final[str] = '504 Gateway Timeout' -HTTP_GATEWAY_TIMEOUT = HTTP_504 +HTTP_GATEWAY_TIMEOUT: Final[str] = HTTP_504 HTTP_505: Final[str] = '505 HTTP Version Not Supported' -HTTP_HTTP_VERSION_NOT_SUPPORTED = HTTP_505 +HTTP_HTTP_VERSION_NOT_SUPPORTED: Final[str] = HTTP_505 HTTP_507: Final[str] = '507 Insufficient Storage' -HTTP_INSUFFICIENT_STORAGE = HTTP_507 +HTTP_INSUFFICIENT_STORAGE: Final[str] = HTTP_507 HTTP_508: Final[str] = '508 Loop Detected' -HTTP_LOOP_DETECTED = HTTP_508 +HTTP_LOOP_DETECTED: Final[str] = HTTP_508 HTTP_511: Final[str] = '511 Network Authentication Required' -HTTP_NETWORK_AUTHENTICATION_REQUIRED = HTTP_511 +HTTP_NETWORK_AUTHENTICATION_REQUIRED: Final[str] = HTTP_511 # 70X - Inexcusable HTTP_701: Final[str] = '701 Meh' diff --git a/tests/test_status_codes.py b/tests/test_status_codes.py index 55f7f1943..b89736883 100644 --- a/tests/test_status_codes.py +++ b/tests/test_status_codes.py @@ -11,16 +11,16 @@ class TestStatusCodes: @pytest.mark.skipif( sys.version_info < (3, 13), reason='Outdated http statuses definitions' ) - def test_statuses_are_in_compliance_with_http_from_python313(self): - for status in status_codes.__all__: - status_code, message = self._status_code_and_message(status) - if status_code >= 700: - pytest.skip('Codes above 700 are not defined in http package') - http_status = http.HTTPStatus(status_code) - if status_code in [413, 418, 422]: - assert http_status.phrase != message - else: - assert http_status.phrase == message + @pytest.mark.parametrize('status', status_codes.__all__) + def test_statuses_are_in_compliance_with_http_from_python313(self, status): + status_code, message = self._status_code_and_message(status) + if status_code >= 700: + pytest.skip('Codes above 700 are not defined in http package') + http_status = http.HTTPStatus(status_code) + if status_code in [413, 418, 422]: + assert http_status.phrase != message + else: + assert http_status.phrase == message def _status_code_and_message(self, status: str) -> Tuple[int, str]: status = getattr(status_codes, status)