Skip to content

Commit aa9a1bb

Browse files
committed
sty: revise tests according to ruff
1 parent fb5c4e0 commit aa9a1bb

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

templateflow/conf/tests/test_conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def test_layout_errors(monkeypatch):
124124
def myfunc():
125125
return 'okay'
126126

127-
def mock_import(name, globals=None, locals=None, fromlist=tuple(), level=0):
127+
def mock_import(name, globals=None, locals=None, fromlist=(), level=0): # noqa: A002
128128
if name == 'bids':
129129
raise ModuleNotFoundError
130130
return oldimport(name, globals=globals, locals=locals, fromlist=fromlist, level=level)

templateflow/conf/tests/test_s3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_get_skel_file(monkeypatch):
3939
assert Path(new_skel).stat().st_size > 0
4040

4141
latest_md5 = (
42-
requests.get(s3.TF_SKEL_URL(release='master', ext='md5', allow_redirects=True))
42+
requests.get(s3.TF_SKEL_URL(release='master', ext='md5', allow_redirects=True), timeout=10)
4343
.content.decode()
4444
.split()[0]
4545
)

templateflow/tests/test_api.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,13 @@ def _parse_bibtex(self):
4646

4747
try:
4848
self.etype = re.search(r'@(\w+)', self.text).group(1)
49-
except AttributeError:
50-
raise TypeError(f'Invalid bibtex: {self.text}')
49+
except AttributeError as err:
50+
raise TypeError(f'Invalid bibtex: {self.text}') from err
5151
try:
5252
self.citekey = re.search(r'@[^{]*{([^,\s]+)', self.text).group(1)
53-
except AttributeError:
54-
raise TypeError(f'Invalid bibtex: {self.text}')
55-
self.pairs = {
56-
key: val for key, val in re.findall(r'(\w+)=(\{[^{}]+\})', self.text)
57-
}
53+
except AttributeError as err:
54+
raise TypeError(f'Invalid bibtex: {self.text}') from err
55+
self.pairs = dict(re.findall(r'(\w+)=(\{[^{}]+\})', self.text))
5856

5957
def get(self, val):
6058
return self.pairs.get(val)
@@ -177,7 +175,7 @@ def assert_same(self, other):
177175

178176

179177
@pytest.mark.parametrize(
180-
'template,urls,fbib,lbib',
178+
('template', 'urls', 'fbib', 'lbib'),
181179
[
182180
('MNI152NLin2009cAsym', mni2009_urls, mni2009_fbib, mni2009_lbib),
183181
('fsLR', fslr_urls, fslr_fbib, fslr_lbib),
@@ -207,8 +205,7 @@ def test_citations(tmp_path, template, urls, fbib, lbib):
207205
assert len(bibs) == 1
208206

209207
else:
210-
# no citations currently
211-
assert False
208+
pytest.fail('no citations currently')
212209

213210

214211
def test_pybids_magic_get():
@@ -224,4 +221,4 @@ def test_pybids_magic_get():
224221
# Existing layout.get_* should not be bubbled to the layout
225222
# (that means, raise an AttributeError instead of a BIDSEntityError)
226223
with pytest.raises(AttributeError):
227-
api.get_fieldmap
224+
_ = api.get_fieldmap

0 commit comments

Comments
 (0)