3
3
from ..split import Split
4
4
5
5
6
- @pytest .mark .xfail ("FSLDIR" not in os .environ , reason = "no FSL found" , raises = FileNotFoundError )
7
- @pytest .mark .parametrize ("inputs, outputs" , [])
6
+ @pytest .mark .xfail (
7
+ "FSLDIR" not in os .environ , reason = "no FSL found" , raises = FileNotFoundError
8
+ )
9
+ @pytest .mark .parametrize (
10
+ "inputs, outputs" ,
11
+ [
12
+ (
13
+ {
14
+ "in_file" : "test.nii.gz" ,
15
+ "output_basename" : "test_split" ,
16
+ "dimension" : "t" ,
17
+ },
18
+ ["out_files" ],
19
+ )
20
+ ],
21
+ )
8
22
def test_Split (test_data , inputs , outputs ):
9
23
if inputs is None :
10
24
in_file = Path (test_data ) / "test.nii.gz"
@@ -31,42 +45,13 @@ def test_Split(test_data, inputs, outputs):
31
45
except :
32
46
pass
33
47
task = Split (** inputs )
34
- assert set (task .generated_output_names ) == set (["return_code" , "stdout" , "stderr" ] + outputs )
48
+ assert set (task .generated_output_names ) == set (
49
+ ["return_code" , "stdout" , "stderr" ] + outputs
50
+ )
35
51
res = task ()
36
52
print ("RESULT: " , res )
37
53
for out_nm in outputs :
38
54
if isinstance (getattr (res .output , out_nm ), list ):
39
55
assert [os .path .exists (x ) for x in getattr (res .output , out_nm )]
40
56
else :
41
57
assert os .path .exists (getattr (res .output , out_nm ))
42
-
43
-
44
- @pytest .mark .parametrize ("inputs, error" , [(None , "AttributeError" )])
45
- def test_Split_exception (test_data , inputs , error ):
46
- if inputs is None :
47
- in_file = Path (test_data ) / "test.nii.gz"
48
- task = Split (in_file = in_file )
49
- else :
50
- for key , val in inputs .items ():
51
- try :
52
- pattern = r"\.[a-zA-Z]*"
53
- if isinstance (val , str ):
54
- if re .findall (pattern , val ) != []:
55
- inputs [key ] = Path (test_data ) / val
56
- elif "_dir" in key :
57
- dirpath = Path (test_data ) / val
58
- if dirpath .exists () and dirpath .is_dir ():
59
- shutil .rmtree (dirpath )
60
- inputs [key ] = Path (test_data ) / val
61
- else :
62
- inputs [key ] = eval (val )
63
- elif isinstance (val , list ):
64
- if all (re .findall (pattern , _ ) != [] for _ in val ):
65
- inputs [key ] = [Path (test_data ) / _ for _ in val ]
66
- else :
67
- inputs [key ] = eval (val )
68
- except :
69
- pass
70
- task = Split (** inputs )
71
- with pytest .raises (eval (error )):
72
- task .generated_output_names
0 commit comments