mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
merge from 3.5
Issue #26892: Honor debuglevel flag in urllib.request.HTTPHandler. Patch contributed by Chi Hsuan Yen.
This commit is contained in:
commit
5d1110a952
3 changed files with 13 additions and 2 deletions
|
@ -480,8 +480,8 @@ class MockHTTPSHandler(urllib.request.AbstractHTTPHandler):
|
|||
# Useful for testing the Proxy-Authorization request by verifying the
|
||||
# properties of httpcon
|
||||
|
||||
def __init__(self):
|
||||
urllib.request.AbstractHTTPHandler.__init__(self)
|
||||
def __init__(self, debuglevel=0):
|
||||
urllib.request.AbstractHTTPHandler.__init__(self, debuglevel=debuglevel)
|
||||
self.httpconn = MockHTTPClass()
|
||||
|
||||
def https_open(self, req):
|
||||
|
@ -950,6 +950,13 @@ class HandlerTests(unittest.TestCase):
|
|||
newreq = h.do_request_(req)
|
||||
self.assertEqual(int(newreq.get_header('Content-length')),16)
|
||||
|
||||
def test_http_handler_debuglevel(self):
|
||||
o = OpenerDirector()
|
||||
h = MockHTTPSHandler(debuglevel=1)
|
||||
o.add_handler(h)
|
||||
o.open("https://www.example.com")
|
||||
self.assertEqual(h._debuglevel, 1)
|
||||
|
||||
def test_http_doubleslash(self):
|
||||
# Checks the presence of any unnecessary double slash in url does not
|
||||
# break anything. Previously, a double slash directly after the host
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue