@@ -222,8 +222,8 @@ def test_password_manager_default_port(self):
222
222
223
223
class MockOpener :
224
224
addheaders = []
225
- def open (self , req , data = None ):
226
- self .req , self .data = req , data
225
+ def open (self , req , data = None , timeout = socket . _GLOBAL_DEFAULT_TIMEOUT ):
226
+ self .req , self .data , self . timeout = req , data , timeout
227
227
def error (self , proto , * args ):
228
228
self .proto , self .args = proto , args
229
229
@@ -854,6 +854,7 @@ def test_redirect(self):
854
854
for data in None , "blah\n blah\n " :
855
855
method = getattr (h , "http_error_%s" % code )
856
856
req = Request (from_url , data )
857
+ req .timeout = socket ._GLOBAL_DEFAULT_TIMEOUT
857
858
req .add_header ("Nonsense" , "viking=withhold" )
858
859
if data is not None :
859
860
req .add_header ("Content-Length" , str (len (data )))
@@ -883,6 +884,7 @@ def test_redirect(self):
883
884
884
885
# loop detection
885
886
req = Request (from_url )
887
+ req .timeout = socket ._GLOBAL_DEFAULT_TIMEOUT
886
888
def redirect (h , req , url = to_url ):
887
889
h .http_error_302 (req , MockFile (), 302 , "Blah" ,
888
890
MockHeaders ({"location" : url }))
@@ -892,6 +894,7 @@ def redirect(h, req, url=to_url):
892
894
# detect infinite loop redirect of a URL to itself
893
895
req = Request (from_url , origin_req_host = "example.com" )
894
896
count = 0
897
+ req .timeout = socket ._GLOBAL_DEFAULT_TIMEOUT
895
898
try :
896
899
while 1 :
897
900
redirect (h , req , "http://example.com/" )
@@ -903,6 +906,7 @@ def redirect(h, req, url=to_url):
903
906
# detect endless non-repeating chain of redirects
904
907
req = Request (from_url , origin_req_host = "example.com" )
905
908
count = 0
909
+ req .timeout = socket ._GLOBAL_DEFAULT_TIMEOUT
906
910
try :
907
911
while 1 :
908
912
redirect (h , req , "http://example.com/%d" % count )
0 commit comments