|
4 | 4 |
|
5 | 5 |
|
6 | 6 | @pytest.mark.xfail("FSLDIR" not in os.environ, reason="no FSL found", raises=FileNotFoundError) |
7 | | -@pytest.mark.parametrize("inputs, outputs", []) |
| 7 | +@pytest.mark.parametrize( |
| 8 | + "inputs, outputs", |
| 9 | + [ |
| 10 | + ( |
| 11 | + { |
| 12 | + "in_file": "test.nii.gz", |
| 13 | + "output_basename": "test_split", |
| 14 | + "dimension": "t", |
| 15 | + }, |
| 16 | + ["out_files"], |
| 17 | + ) |
| 18 | + ], |
| 19 | +) |
8 | 20 | def test_Split(test_data, inputs, outputs): |
9 | 21 | if inputs is None: |
10 | 22 | in_file = Path(test_data) / "test.nii.gz" |
@@ -39,34 +51,3 @@ def test_Split(test_data, inputs, outputs): |
39 | 51 | assert [os.path.exists(x) for x in getattr(res.output, out_nm)] |
40 | 52 | else: |
41 | 53 | 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