Skip to content

Commit 011a523

Browse files
committed
Remove failed connection handler from esa.hsa tests
Rerunning remote tests that have failed because of a connection failure can be done with the `pytest-rerunfailures` plugin for `pytest`, so custom code for handling that in `esa.hsa` can be safely removed.
1 parent 1aad0a7 commit 011a523

File tree

1 file changed

+8
-35
lines changed

1 file changed

+8
-35
lines changed

astroquery/esa/hsa/tests/test_hsa_remote.py

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import tarfile
44

55
import pytest
6-
from requests.exceptions import ChunkedEncodingError
76

87
from ..core import HSAClass
98

@@ -20,16 +19,6 @@
2019

2120
@pytest.mark.remote_data
2221
class TestHSARemote:
23-
retries = 2
24-
25-
def access_archive_with_retries(self, f, params):
26-
for _ in range(self.retries):
27-
try:
28-
res = f(**params)
29-
return res
30-
except ChunkedEncodingError:
31-
pass
32-
return None
3322

3423
def test_download_data_observation_pacs(self, tmp_path):
3524
obs_id = "1342191813"
@@ -41,9 +30,7 @@ def test_download_data_observation_pacs(self, tmp_path):
4130
'download_dir': tmp_path}
4231
expected_res = Path(tmp_path, obs_id + ".tar")
4332
hsa = HSAClass()
44-
res = self.access_archive_with_retries(hsa.download_data, parameters)
45-
if res is None:
46-
pytest.xfail(f"Archive broke the connection {self.retries} times, unable to test")
33+
res = hsa.download_data(**parameters)
4734
assert Path(res) == expected_res
4835
assert Path(res).is_file()
4936
with tarfile.open(res) as tar:
@@ -64,9 +51,7 @@ def test_download_data_observation_pacs_filename(self, tmp_path):
6451
'download_dir': tmp_path}
6552
expected_res = Path(tmp_path, fname + ".tar")
6653
hsa = HSAClass()
67-
res = self.access_archive_with_retries(hsa.download_data, parameters)
68-
if res is None:
69-
pytest.xfail(f"Archive broke the connection {self.retries} times, unable to test")
54+
res = hsa.download_data(**parameters)
7055
assert Path(res) == expected_res
7156
assert Path(res).is_file()
7257
with tarfile.open(res) as tar:
@@ -86,9 +71,7 @@ def test_download_data_observation_pacs_compressed(self, tmp_path):
8671
'download_dir': tmp_path}
8772
expected_res = Path(tmp_path, obs_id + ".tgz")
8873
hsa = HSAClass()
89-
res = self.access_archive_with_retries(hsa.download_data, parameters)
90-
if res is None:
91-
pytest.xfail(f"Archive broke the connection {self.retries} times, unable to test")
74+
res = hsa.download_data(**parameters)
9275
assert Path(res) == expected_res
9376
assert Path(res).is_file()
9477
with tarfile.open(res) as tar:
@@ -107,9 +90,7 @@ def test_download_data_observation_spire(self, tmp_path):
10790
'download_dir': tmp_path}
10891
expected_res = Path(tmp_path, obs_id + ".tar")
10992
hsa = HSAClass()
110-
res = self.access_archive_with_retries(hsa.download_data, parameters)
111-
if res is None:
112-
pytest.xfail(f"Archive broke the connection {self.retries} times, unable to test")
93+
res = hsa.download_data(**parameters)
11394
assert Path(res) == expected_res
11495
assert Path(res).is_file()
11596
with tarfile.open(res) as tar:
@@ -127,9 +108,7 @@ def test_download_data_postcard_pacs(self, tmp_path):
127108
'download_dir': tmp_path}
128109
expected_res = Path(tmp_path, obs_id + ".jpg")
129110
hsa = HSAClass()
130-
res = self.access_archive_with_retries(hsa.download_data, parameters)
131-
if res is None:
132-
pytest.xfail(f"Archive broke the connection {self.retries} times, unable to test")
111+
res = hsa.download_data(**parameters)
133112
assert Path(res) == expected_res
134113
assert Path(res).is_file()
135114

@@ -144,9 +123,7 @@ def test_download_data_postcard_pacs_filename(self, tmp_path):
144123
'download_dir': tmp_path}
145124
expected_res = Path(tmp_path, fname + ".jpg")
146125
hsa = HSAClass()
147-
res = self.access_archive_with_retries(hsa.download_data, parameters)
148-
if res is None:
149-
pytest.xfail(f"Archive broke the connection {self.retries} times, unable to test")
126+
res = hsa.download_data(**parameters)
150127
assert Path(res) == expected_res
151128
assert Path(res).is_file()
152129

@@ -159,9 +136,7 @@ def test_get_observation(self, tmp_path):
159136
'download_dir': tmp_path}
160137
expected_res = Path(tmp_path, obs_id + ".tar")
161138
hsa = HSAClass()
162-
res = self.access_archive_with_retries(hsa.get_observation, parameters)
163-
if res is None:
164-
pytest.xfail(f"Archive broke the connection {self.retries} times, unable to test")
139+
res = hsa.get_observation(**parameters)
165140
assert Path(res) == expected_res
166141
assert Path(res).is_file()
167142
with tarfile.open(res) as tar:
@@ -178,8 +153,6 @@ def test_get_postcard(self, tmp_path):
178153
'download_dir': tmp_path}
179154
expected_res = Path(tmp_path, obs_id + ".jpg")
180155
hsa = HSAClass()
181-
res = self.access_archive_with_retries(hsa.get_postcard, parameters)
182-
if res is None:
183-
pytest.xfail(f"Archive broke the connection {self.retries} times, unable to test")
156+
res = hsa.get_postcard(**parameters)
184157
assert Path(res) == expected_res
185158
assert Path(res).is_file()

0 commit comments

Comments
 (0)