@@ -256,12 +256,24 @@ def test_download_ephem(ephem_download_path, fileinfo):
256256
257257 remove_download_eph (ephem_download_path )
258258
259+ def download_igs (requests_url ):
260+ """Helper function to capture ConnectionError.
261+
262+ """
263+ response = None
264+ try :
265+ response = requests .get (requests_url , timeout = 5 )
266+ except requests .exceptions .ConnectionError :
267+ print ("ConnectionError." )
268+
269+ return response
270+
259271@pytest .mark .parametrize ('fileinfo' ,
260272 [
261273 {'filepath' : 'IGS/BRDC/2023/099/BRDC00WRD_S_20230990000_01D_MN.rnx.gz' ,
262274 'url' : 'http://igs.bkg.bund.de/root_ftp/' },
263275 ])
264- def test_request_igs (ephem_download_path , fileinfo ):
276+ def test_request_igs (capsys , ephem_download_path , fileinfo ):
265277 """Test requests download for igs files.
266278
267279 The reason for this test is that Github workflow actions seem to
@@ -287,14 +299,17 @@ def test_request_igs(ephem_download_path, fileinfo):
287299
288300 requests_url = fileinfo ['url' ] + fileinfo ['filepath' ]
289301
290-
291302 fail_count = 0
292- while fail_count < 3 :
293- try :
294- response = requests .get (requests_url , timeout = 5 )
295- break
296- except ConnectionError :
303+ while fail_count < 3 :# download the ephemeris file
304+ response = download_igs (requests_url )
305+ captured = capsys .readouterr ()
306+ if "ConnectionError." in captured .out :
297307 fail_count += 1
308+ else :
309+ break
310+
311+ if response is None :
312+ raise requests .exceptions .ConnectionError ("IGS ConnectionError." )
298313
299314 with open (dest_filepath ,'wb' ) as file :
300315 file .write (response .content )
0 commit comments