Skip to content

Commit 09ff390

Browse files
author
HuiQian Tan
committed
applied black and added testcase
1 parent 5aab76a commit 09ff390

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

nipype/interfaces/dcm2nii.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -495,4 +495,6 @@ def _list_outputs(self):
495495

496496
# https://stackoverflow.com/a/4829130
497497
def search_files(prefix, outtypes):
498-
return it.chain.from_iterable(iglob(glob.escape(prefix + outtype)) for outtype in outtypes)
498+
return it.chain.from_iterable(
499+
iglob(glob.escape(prefix + outtype)) for outtype in outtypes
500+
)
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import pytest
2+
3+
4+
from nipype.interfaces import dcm2nii
5+
6+
7+
@pytest.mark.parametrize(
8+
"fname, extension",
9+
[
10+
("output_1", ".txt"),
11+
("output_w_[]_meta_1", ".json"),
12+
("output_w_**^$?_meta_2", ".txt"),
13+
],
14+
)
15+
def test_search_files(tmp_path, fname, extension):
16+
tmp_fname = fname + extension
17+
test_file = tmp_path / tmp_fname
18+
test_file.touch()
19+
actual_files_list = dcm2nii.search_files(str(tmp_path / fname), [extension])
20+
for f in actual_files_list:
21+
assert str(test_file) == f

0 commit comments

Comments
 (0)