diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index 82279110044..1c30e9bacde 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -301,10 +301,11 @@ class MockHTTPClass: else: self._tunnel_headers.clear() - def request(self, method, url, body=None, headers={}): + def request(self, method, url, body=None, headers=None): self.method = method self.selector = url - self.req_headers += headers.items() + if headers is not None: + self.req_headers += headers.items() self.req_headers.sort() if body: self.data = body @@ -424,7 +425,11 @@ class MockHTTPHandler(urllib.request.BaseHandler): class MockHTTPSHandler(urllib.request.AbstractHTTPHandler): # Useful for testing the Proxy-Authorization request by verifying the # properties of httpcon - httpconn = MockHTTPClass() + + def __init__(self): + urllib.request.AbstractHTTPHandler.__init__(self) + self.httpconn = MockHTTPClass() + def https_open(self, req): return self.do_open(self.httpconn, req)