5
5
from ..cli import cli_apply , main as ntcli
6
6
7
7
8
- def test_cli ():
8
+ def test_cli (capsys ):
9
9
# empty command
10
10
with pytest .raises (SystemExit ):
11
11
ntcli ()
12
12
# invalid command
13
13
with pytest .raises (SystemExit ):
14
14
ntcli (['idk' ])
15
15
16
-
17
- def test_help (capsys ):
18
16
with pytest .raises (SystemExit ) as sysexit :
19
17
ntcli (['-h' ])
20
18
console = capsys .readouterr ()
@@ -26,23 +24,27 @@ def test_help(capsys):
26
24
ntcli (['apply' , '-h' ])
27
25
console = capsys .readouterr ()
28
26
assert dedent (cli_apply .__doc__ ) in console .out
27
+ assert sysexit .value .code == 0
29
28
30
29
31
30
def test_apply_linear (tmpdir , data_path , get_testdata ):
32
31
tmpdir .chdir ()
33
32
img = 'img.nii.gz'
34
33
get_testdata ['RAS' ].to_filename (img )
35
34
lin_xform = str (data_path / 'affine-RAS.itk.tfm' )
35
+ lin_xform2 = str (data_path / 'affine-RAS.fs.lta' )
36
36
37
37
# unknown transformation format
38
38
with pytest .raises (ValueError ):
39
39
ntcli (['apply' , 'unsupported.xform' , 'img.nii.gz' ])
40
40
41
41
# linear transform arguments
42
- largs = ['apply' , lin_xform , img , '--ref' , img ]
43
- ntcli (largs )
44
- output = 'nt_img.nii.gz'
45
- assert (tmpdir / output ).check ()
42
+ output = tmpdir / 'nt_img.nii.gz'
43
+ ntcli (['apply' , lin_xform , img , '--ref' , img ])
44
+ assert output .check ()
45
+ output .remove ()
46
+ ntcli (['apply' , lin_xform2 , img , '--ref' , img ])
47
+ assert output .check ()
46
48
47
49
48
50
def test_apply_nl (tmpdir , data_path ):
0 commit comments