Skip to content

Commit

Permalink
applied black and added testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
HuiQian Tan committed Dec 6, 2021
1 parent 5aab76a commit 09ff390
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nipype/interfaces/dcm2nii.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,4 +495,6 @@ def _list_outputs(self):

# https://stackoverflow.com/a/4829130
def search_files(prefix, outtypes):
return it.chain.from_iterable(iglob(glob.escape(prefix + outtype)) for outtype in outtypes)
return it.chain.from_iterable(
iglob(glob.escape(prefix + outtype)) for outtype in outtypes
)
21 changes: 21 additions & 0 deletions nipype/interfaces/tests/test_dcm2nii.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pytest


from nipype.interfaces import dcm2nii


@pytest.mark.parametrize(
"fname, extension",
[
("output_1", ".txt"),
("output_w_[]_meta_1", ".json"),
("output_w_**^$?_meta_2", ".txt"),
],
)
def test_search_files(tmp_path, fname, extension):
tmp_fname = fname + extension
test_file = tmp_path / tmp_fname
test_file.touch()
actual_files_list = dcm2nii.search_files(str(tmp_path / fname), [extension])
for f in actual_files_list:
assert str(test_file) == f

0 comments on commit 09ff390

Please sign in to comment.