Skip to content

Commit caa8a7c

Browse files
committed
FIX: use temp directory for download testing
1 parent 98945db commit caa8a7c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

astroquery/esa/utils/tests/test_utils.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def test_get_degree_radius(self):
122122
assert esautils.get_degree_radius(12) == 12.0
123123
assert esautils.get_degree_radius(30 * u.arcmin) == 0.5
124124

125-
def test_download_table(self):
125+
def test_download_table(self, tmp_cwd):
126126
dummy_table = get_dummy_table()
127127
filename = 'test.votable'
128128
esautils.download_table(dummy_table, output_file=filename, output_format='votable')
@@ -159,7 +159,7 @@ def test_execute_servlet_request_error(self, mock_tap):
159159
assert error_message in err.value.args[0]
160160

161161
@patch("pyvo.auth.authsession.AuthSession.get")
162-
def test_download_local(self, mock_get):
162+
def test_download_local(self, mock_get, tmp_cwd):
163163
iter_content_mock = get_iter_content_mock()
164164
mock_response = Mock()
165165
mock_response.iter_content.side_effect = iter_content_mock
@@ -172,15 +172,15 @@ def test_download_local(self, mock_get):
172172

173173
filename = 'test_file.fits'
174174
esautils.download_file(url='http://dummyurl.com/download', session=esa_session,
175-
params={'file': filename}, path='', filename=filename)
175+
params={'file': filename}, filename=filename)
176176

177177
mock_get.assert_called_once_with('http://dummyurl.com/download', stream=True,
178178
params={'file': filename, 'TAPCLIENT': 'ASTROQUERY'})
179179

180180
assert os.path.exists(filename)
181181

182182
@patch("pyvo.auth.authsession.AuthSession.get")
183-
def test_download_cache(self, mock_get):
183+
def test_download_cache(self, mock_get, tmp_cwd):
184184
iter_content_mock = get_iter_content_mock()
185185
mock_response = Mock()
186186
mock_response.iter_content.side_effect = iter_content_mock
@@ -194,7 +194,7 @@ def test_download_cache(self, mock_get):
194194
filename = 'test_file2.fits'
195195
cache_folder = './cache/'
196196
esautils.download_file(url='http://dummyurl.com/download', session=esa_session,
197-
params={'file': filename}, path='', filename=filename,
197+
params={'file': filename}, filename=filename,
198198
cache=True, cache_folder=cache_folder)
199199

200200
mock_get.assert_called_once_with('http://dummyurl.com/download', stream=True,
@@ -203,7 +203,7 @@ def test_download_cache(self, mock_get):
203203
assert not os.path.exists(filename)
204204
assert os.path.exists(esautils.get_cache_filepath(filename=filename, cache_path=cache_folder))
205205

206-
def test_read_tar(self):
206+
def test_read_tar(self, tmp_cwd):
207207
tar_file = data_path('tar_file.tar')
208208

209209
files = esautils.read_downloaded_fits([tar_file])
@@ -213,7 +213,7 @@ def test_read_tar(self):
213213

214214
close_files(files)
215215

216-
def test_read_tar_gz(self):
216+
def test_read_tar_gz(self, tmp_cwd):
217217
tar_gz_file = data_path('tar_gz_file.tar.gz')
218218

219219
files = esautils.read_downloaded_fits([tar_gz_file])
@@ -224,7 +224,7 @@ def test_read_tar_gz(self):
224224

225225
close_files(files)
226226

227-
def test_read_zip(self):
227+
def test_read_zip(self, tmp_cwd):
228228
zip_file = data_path('tar_file.tar')
229229

230230
files = esautils.read_downloaded_fits([zip_file])
@@ -234,7 +234,7 @@ def test_read_zip(self):
234234

235235
close_files(files)
236236

237-
def test_read_uncompressed(self):
237+
def test_read_uncompressed(self, tmp_cwd):
238238
uncompressed_file = data_path('test.fits')
239239

240240
files = esautils.read_downloaded_fits([uncompressed_file])

0 commit comments

Comments
 (0)