Skip to content

Commit 4261d19

Browse files
authored
Merge pull request #486 from me-pic/bug/fetch_tests
Fix files fetching from osf
2 parents 63c3d83 + e3eff0a commit 4261d19

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

phys2bids/tests/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import os
22
import ssl
3-
from urllib.request import urlretrieve
43

54
import pytest
5+
import requests
66

77

88
def pytest_addoption(parser):
@@ -50,7 +50,11 @@ def fetch_file(osf_id, path, filename):
5050
url = "https://osf.io/{}/download".format(osf_id)
5151
full_path = os.path.join(path, filename)
5252
if not os.path.isfile(full_path):
53-
urlretrieve(url, full_path)
53+
req = requests.get(url, allow_redirects=True)
54+
req.raise_for_status()
55+
with open(full_path, "wb") as f:
56+
f.write(req.content)
57+
f.close()
5458
return full_path
5559

5660

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ test =
6262
pytest >=5.3
6363
pytest-cov
6464
coverage
65+
requests
6566
%(interfaces)s
6667
%(style)s
6768
all =

0 commit comments

Comments
 (0)