Skip to content

Commit 37e1c75

Browse files
committed
Added more tests
1 parent 16c621d commit 37e1c75

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

nipype/utils/tests/test_cmd.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,100 @@ def test_main_returns_0_on_help(self):
5151
optional arguments:
5252
-h, --help show this help message and exit
5353
""")
54+
55+
def test_list_nipy_interfacesp(self):
56+
with self.assertRaises(SystemExit) as cm:
57+
with capture_sys_output() as (stdout, stderr):
58+
nipype_cmd.main(['nipype_cmd', 'nipype.interfaces.nipy'])
59+
60+
exit_exception = cm.exception
61+
self.assertEqual(exit_exception.code, 0)
62+
63+
self.assertEqual(stderr.getvalue(), '')
64+
self.assertEqual(stdout.getvalue(),
65+
"""Available Interfaces:
66+
SpaceTimeRealigner
67+
Similarity
68+
ComputeMask
69+
FitGLM
70+
EstimateContrast
71+
FmriRealign4d
72+
""")
73+
74+
def test_run_4d_realign_without_arguments(self):
75+
with self.assertRaises(SystemExit) as cm:
76+
with capture_sys_output() as (stdout, stderr):
77+
nipype_cmd.main(['nipype_cmd', 'nipype.interfaces.nipy', 'FmriRealign4d'])
78+
79+
exit_exception = cm.exception
80+
self.assertEqual(exit_exception.code, 2)
81+
82+
self.assertEqual(stderr.getvalue(),
83+
"""usage: nipype_cmd nipype.interfaces.nipy FmriRealign4d [-h]
84+
[--between_loops BETWEEN_LOOPS]
85+
[--ignore_exception IGNORE_EXCEPTION]
86+
[--loops LOOPS]
87+
[--slice_order SLICE_ORDER]
88+
[--speedup SPEEDUP]
89+
[--start START]
90+
[--time_interp TIME_INTERP]
91+
[--tr_slices TR_SLICES]
92+
in_file tr
93+
nipype_cmd nipype.interfaces.nipy FmriRealign4d: error: too few arguments
94+
""")
95+
self.assertEqual(stdout.getvalue(), '')
96+
97+
def test_run_4d_realign_help(self):
98+
with self.assertRaises(SystemExit) as cm:
99+
with capture_sys_output() as (stdout, stderr):
100+
nipype_cmd.main(['nipype_cmd', 'nipype.interfaces.nipy', 'FmriRealign4d', '-h'])
101+
102+
exit_exception = cm.exception
103+
self.assertEqual(exit_exception.code, 0)
104+
105+
self.assertEqual(stderr.getvalue(), '')
106+
self.assertEqual(stdout.getvalue(),
107+
"""usage: nipype_cmd nipype.interfaces.nipy FmriRealign4d [-h]
108+
[--between_loops BETWEEN_LOOPS]
109+
[--ignore_exception IGNORE_EXCEPTION]
110+
[--loops LOOPS]
111+
[--slice_order SLICE_ORDER]
112+
[--speedup SPEEDUP]
113+
[--start START]
114+
[--time_interp TIME_INTERP]
115+
[--tr_slices TR_SLICES]
116+
in_file tr
117+
118+
Run FmriRealign4d
119+
120+
positional arguments:
121+
in_file File to realign
122+
tr TR in seconds
123+
124+
optional arguments:
125+
-h, --help show this help message and exit
126+
--between_loops BETWEEN_LOOPS
127+
loops used to realign different runs
128+
--ignore_exception IGNORE_EXCEPTION
129+
Print an error message instead of throwing an
130+
exception in case the interface fails to run
131+
--loops LOOPS loops within each run
132+
--slice_order SLICE_ORDER
133+
0 based slice order. This would be equivalent to
134+
enteringnp.argsort(spm_slice_order) for this field.
135+
This effectsinterleaved acquisition. This field will
136+
be deprecated infuture Nipy releases and be replaced
137+
by actual sliceacquisition times.
138+
--speedup SPEEDUP successive image sub-sampling factors for acceleration
139+
--start START time offset into TR to align slices to
140+
--time_interp TIME_INTERP
141+
Assume smooth changes across time e.g., fmri series.
142+
If you don't want slice timing correction set this to
143+
undefined
144+
--tr_slices TR_SLICES
145+
TR slices
146+
""")
147+
54148

55149
if __name__ == '__main__':
56150
unittest.main()

0 commit comments

Comments
 (0)