mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #23439: Add missing entries to http.client.__all__.
Also, document the LineTooLong exception since it can be raised by the members of public API (e.g. http.client.HTTPResponse). Patch by Martin Panter.
This commit is contained in:
commit
8e28679417
3 changed files with 24 additions and 1 deletions
|
@ -169,6 +169,12 @@ The following exceptions are raised as appropriate:
|
||||||
status code that we don't understand.
|
status code that we don't understand.
|
||||||
|
|
||||||
|
|
||||||
|
.. exception:: LineTooLong
|
||||||
|
|
||||||
|
A subclass of :exc:`HTTPException`. Raised if an excessively long line
|
||||||
|
is received in the HTTP protocol from the server.
|
||||||
|
|
||||||
|
|
||||||
The constants defined in this module are:
|
The constants defined in this module are:
|
||||||
|
|
||||||
.. data:: HTTP_PORT
|
.. data:: HTTP_PORT
|
||||||
|
|
|
@ -75,12 +75,14 @@ import socket
|
||||||
import collections
|
import collections
|
||||||
from urllib.parse import urlsplit
|
from urllib.parse import urlsplit
|
||||||
|
|
||||||
|
# HTTPMessage, parse_headers(), and the HTTP status code constants are
|
||||||
|
# intentionally omitted for simplicity
|
||||||
__all__ = ["HTTPResponse", "HTTPConnection",
|
__all__ = ["HTTPResponse", "HTTPConnection",
|
||||||
"HTTPException", "NotConnected", "UnknownProtocol",
|
"HTTPException", "NotConnected", "UnknownProtocol",
|
||||||
"UnknownTransferEncoding", "UnimplementedFileMode",
|
"UnknownTransferEncoding", "UnimplementedFileMode",
|
||||||
"IncompleteRead", "InvalidURL", "ImproperConnectionState",
|
"IncompleteRead", "InvalidURL", "ImproperConnectionState",
|
||||||
"CannotSendRequest", "CannotSendHeader", "ResponseNotReady",
|
"CannotSendRequest", "CannotSendHeader", "ResponseNotReady",
|
||||||
"BadStatusLine", "error", "responses"]
|
"BadStatusLine", "LineTooLong", "error", "responses"]
|
||||||
|
|
||||||
HTTP_PORT = 80
|
HTTP_PORT = 80
|
||||||
HTTPS_PORT = 443
|
HTTPS_PORT = 443
|
||||||
|
|
|
@ -920,7 +920,22 @@ class Readliner:
|
||||||
self.remainder = b"".join(data)
|
self.remainder = b"".join(data)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
class OfflineTest(TestCase):
|
class OfflineTest(TestCase):
|
||||||
|
def test_all(self):
|
||||||
|
# Documented objects defined in the module should be in __all__
|
||||||
|
expected = {"responses"} # White-list documented dict() object
|
||||||
|
# HTTPMessage, parse_headers(), and the HTTP status code constants are
|
||||||
|
# intentionally omitted for simplicity
|
||||||
|
blacklist = {"HTTPMessage", "parse_headers"}
|
||||||
|
for name in dir(client):
|
||||||
|
if name in blacklist:
|
||||||
|
continue
|
||||||
|
module_object = getattr(client, name)
|
||||||
|
if getattr(module_object, "__module__", None) == "http.client":
|
||||||
|
expected.add(name)
|
||||||
|
self.assertCountEqual(client.__all__, expected)
|
||||||
|
|
||||||
def test_responses(self):
|
def test_responses(self):
|
||||||
self.assertEqual(client.responses[client.NOT_FOUND], "Not Found")
|
self.assertEqual(client.responses[client.NOT_FOUND], "Not Found")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue