@@ -222,8 +222,8 @@ def test_password_manager_default_port(self):
222222
223223class MockOpener :
224224 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
227227 def error (self , proto , * args ):
228228 self .proto , self .args = proto , args
229229
@@ -854,6 +854,7 @@ def test_redirect(self):
854854 for data in None , "blah\n blah\n " :
855855 method = getattr (h , "http_error_%s" % code )
856856 req = Request (from_url , data )
857+ req .timeout = socket ._GLOBAL_DEFAULT_TIMEOUT
857858 req .add_header ("Nonsense" , "viking=withhold" )
858859 if data is not None :
859860 req .add_header ("Content-Length" , str (len (data )))
@@ -883,6 +884,7 @@ def test_redirect(self):
883884
884885 # loop detection
885886 req = Request (from_url )
887+ req .timeout = socket ._GLOBAL_DEFAULT_TIMEOUT
886888 def redirect (h , req , url = to_url ):
887889 h .http_error_302 (req , MockFile (), 302 , "Blah" ,
888890 MockHeaders ({"location" : url }))
@@ -892,6 +894,7 @@ def redirect(h, req, url=to_url):
892894 # detect infinite loop redirect of a URL to itself
893895 req = Request (from_url , origin_req_host = "example.com" )
894896 count = 0
897+ req .timeout = socket ._GLOBAL_DEFAULT_TIMEOUT
895898 try :
896899 while 1 :
897900 redirect (h , req , "http://example.com/" )
@@ -903,6 +906,7 @@ def redirect(h, req, url=to_url):
903906 # detect endless non-repeating chain of redirects
904907 req = Request (from_url , origin_req_host = "example.com" )
905908 count = 0
909+ req .timeout = socket ._GLOBAL_DEFAULT_TIMEOUT
906910 try :
907911 while 1 :
908912 redirect (h , req , "http://example.com/%d" % count )
0 commit comments