File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Open diff view settings
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Open diff view settings
Original file line number Diff line number Diff line change @@ -107,6 +107,20 @@ def test_http_error(self):
107107 self .fetcher .fetch (self .url )
108108 self .assertEqual (cm .exception .status_code , 404 )
109109
110+ # Read timeout error
111+ def test_read_timeout (self ):
112+ # Reduce the read socket timeout to speed up the test
113+ # while keeping the connect timeout
114+ default_socket_timeout = self .fetcher .socket_timeout
115+ self .fetcher .socket_timeout = (default_socket_timeout , 0.1 )
116+ # Launch a new "slow retrieval" server sending one byte each 40s
117+ slow_server_process_handler = utils .TestServerProcess (log = logger , server = 'slow_retrieval_server.py' )
118+ self .url = f"http://{ utils .TEST_HOST_ADDRESS } :{ str (slow_server_process_handler .port )} /{ self .rel_target_filepath } "
119+ with self .assertRaises (exceptions .SlowRetrievalError ):
120+ next (self .fetcher .fetch (self .url ))
121+
122+ slow_server_process_handler .clean ()
123+
110124 # Simple bytes download
111125 def test_download_bytes (self ):
112126 data = self .fetcher .download_bytes (self .url , self .file_length )
You can’t perform that action at this time.
0 commit comments