summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2015-02-20 12:57:31 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2015-02-20 12:57:31 (GMT)
commitabbf0f40bb91be45b282c7a95161297b2618622a (patch)
treeaa86705d0d09e9e617013181fd5210421fa64f8d
parent79d8f3f1238ab5c86eff2e40e302f678fa24fea3 (diff)
downloadcpython-abbf0f40bb91be45b282c7a95161297b2618622a.zip
cpython-abbf0f40bb91be45b282c7a95161297b2618622a.tar.gz
cpython-abbf0f40bb91be45b282c7a95161297b2618622a.tar.bz2
Issue #23442: Rename two member names to stay backward compatible
with the constants in http.client. Initial patch by Demian Brecht.
-rw-r--r--Lib/http/__init__.py8
-rw-r--r--Lib/test/test_httplib.py61
2 files changed, 65 insertions, 4 deletions
diff --git a/Lib/http/__init__.py b/Lib/http/__init__.py
index 475f1c0..d4334cc 100644
--- a/Lib/http/__init__.py
+++ b/Lib/http/__init__.py
@@ -93,8 +93,8 @@ class HTTPStatus(IntEnum):
'URI is too long')
UNSUPPORTED_MEDIA_TYPE = (415, 'Unsupported Media Type',
'Entity body in unsupported format')
- REQUEST_RANGE_NOT_SATISFIABLE = (416,
- 'Request Range Not Satisfiable',
+ REQUESTED_RANGE_NOT_SATISFIABLE = (416,
+ 'Requested Range Not Satisfiable',
'Cannot satisfy request range')
EXPECTATION_FAILED = (417, 'Expectation Failed',
'Expect condition could not be satisfied')
@@ -107,8 +107,8 @@ class HTTPStatus(IntEnum):
TOO_MANY_REQUESTS = (429, 'Too Many Requests',
'The user has sent too many requests in '
'a given amount of time ("rate limiting")')
- REQUEST_HEADER_FIELD_TOO_LARGE = (431,
- 'Request Header Field Too Large',
+ REQUEST_HEADER_FIELDS_TOO_LARGE = (431,
+ 'Request Header Fields Too Large',
'The server is unwilling to process the request because its header '
'fields are too large')
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index 088bf73..50ddf18 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -939,6 +939,67 @@ class OfflineTest(TestCase):
def test_responses(self):
self.assertEqual(client.responses[client.NOT_FOUND], "Not Found")
+ def test_client_constants(self):
+ # Make sure we don't break backward compatibility with 3.4
+ expected = [
+ 'CONTINUE',
+ 'SWITCHING_PROTOCOLS',
+ 'PROCESSING',
+ 'OK',
+ 'CREATED',
+ 'ACCEPTED',
+ 'NON_AUTHORITATIVE_INFORMATION',
+ 'NO_CONTENT',
+ 'RESET_CONTENT',
+ 'PARTIAL_CONTENT',
+ 'MULTI_STATUS',
+ 'IM_USED',
+ 'MULTIPLE_CHOICES',
+ 'MOVED_PERMANENTLY',
+ 'FOUND',
+ 'SEE_OTHER',
+ 'NOT_MODIFIED',
+ 'USE_PROXY',
+ 'TEMPORARY_REDIRECT',
+ 'BAD_REQUEST',
+ 'UNAUTHORIZED',
+ 'PAYMENT_REQUIRED',
+ 'FORBIDDEN',
+ 'NOT_FOUND',
+ 'METHOD_NOT_ALLOWED',
+ 'NOT_ACCEPTABLE',
+ 'PROXY_AUTHENTICATION_REQUIRED',
+ 'REQUEST_TIMEOUT',
+ 'CONFLICT',
+ 'GONE',
+ 'LENGTH_REQUIRED',
+ 'PRECONDITION_FAILED',
+ 'REQUEST_ENTITY_TOO_LARGE',
+ 'REQUEST_URI_TOO_LONG',
+ 'UNSUPPORTED_MEDIA_TYPE',
+ 'REQUESTED_RANGE_NOT_SATISFIABLE',
+ 'EXPECTATION_FAILED',
+ 'UNPROCESSABLE_ENTITY',
+ 'LOCKED',
+ 'FAILED_DEPENDENCY',
+ 'UPGRADE_REQUIRED',
+ 'PRECONDITION_REQUIRED',
+ 'TOO_MANY_REQUESTS',
+ 'REQUEST_HEADER_FIELDS_TOO_LARGE',
+ 'INTERNAL_SERVER_ERROR',
+ 'NOT_IMPLEMENTED',
+ 'BAD_GATEWAY',
+ 'SERVICE_UNAVAILABLE',
+ 'GATEWAY_TIMEOUT',
+ 'HTTP_VERSION_NOT_SUPPORTED',
+ 'INSUFFICIENT_STORAGE',
+ 'NOT_EXTENDED',
+ 'NETWORK_AUTHENTICATION_REQUIRED',
+ ]
+ for const in expected:
+ with self.subTest(constant=const):
+ self.assertTrue(hasattr(client, const))
+
class SourceAddressTest(TestCase):
def setUp(self):