Skip to content

Commit aee2c92

Browse files
committed
TEST: Remove redundant raises check, autoclear registry
1 parent 2ecccba commit aee2c92

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

sdcflows/tests/test_fieldmaps.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
from .. import fieldmaps as fm
2929

3030

31+
@pytest.fixture(autouse=True)
32+
def clear_registry():
33+
fm.clear_registry()
34+
yield
35+
fm.clear_registry()
36+
37+
3138
def test_FieldmapFile(dsA_dir):
3239
"""Test one existing file."""
3340
f1 = fm.FieldmapFile(dsA_dir / "sub-01" / "anat" / "sub-01_T1w.nii.gz")
@@ -45,13 +52,12 @@ def test_FieldmapFile(dsA_dir):
4552

4653

4754
@pytest.mark.parametrize(
48-
"inputfiles,method,nsources,raises",
55+
"inputfiles,method,nsources",
4956
[
5057
(
5158
("fmap/sub-01_fieldmap.nii.gz", "fmap/sub-01_magnitude.nii.gz"),
5259
fm.EstimatorType.MAPPED,
5360
2,
54-
False,
5561
),
5662
(
5763
(
@@ -62,51 +68,37 @@ def test_FieldmapFile(dsA_dir):
6268
),
6369
fm.EstimatorType.PHASEDIFF,
6470
4,
65-
False,
6671
),
6772
(
6873
("fmap/sub-01_phase1.nii.gz", "fmap/sub-01_phase2.nii.gz"),
6974
fm.EstimatorType.PHASEDIFF,
7075
4,
71-
True,
7276
),
73-
(("fmap/sub-01_phase2.nii.gz",), fm.EstimatorType.PHASEDIFF, 4, True),
74-
(("fmap/sub-01_phase1.nii.gz",), fm.EstimatorType.PHASEDIFF, 4, True),
77+
(("fmap/sub-01_phase2.nii.gz",), fm.EstimatorType.PHASEDIFF, 4),
78+
(("fmap/sub-01_phase1.nii.gz",), fm.EstimatorType.PHASEDIFF, 4),
7579
(
7680
("fmap/sub-01_dir-LR_epi.nii.gz", "fmap/sub-01_dir-RL_epi.nii.gz"),
7781
fm.EstimatorType.PEPOLAR,
7882
2,
79-
False,
8083
),
8184
(
8285
("fmap/sub-01_dir-LR_epi.nii.gz", "dwi/sub-01_dir-RL_sbref.nii.gz"),
8386
fm.EstimatorType.PEPOLAR,
8487
2,
85-
False,
8688
),
8789
(
8890
("anat/sub-01_T1w.nii.gz", "dwi/sub-01_dir-RL_sbref.nii.gz"),
8991
fm.EstimatorType.ANAT,
9092
2,
91-
False,
9293
),
9394
],
9495
)
95-
def test_FieldmapEstimation(dsA_dir, inputfiles, method, nsources, raises):
96+
def test_FieldmapEstimation(dsA_dir, inputfiles, method, nsources):
9697
"""Test errors."""
9798
sub_dir = dsA_dir / "sub-01"
9899

99100
sources = [sub_dir / f for f in inputfiles]
100101

101-
if raises is True:
102-
# Ensure that _estimators is still holding values from previous
103-
# parameter set of this parametrized execution.
104-
with pytest.raises(ValueError):
105-
fm.FieldmapEstimation(sources)
106-
107-
# Clean up so this parameter set can be tested.
108-
fm.clear_registry()
109-
110102
fe = fm.FieldmapEstimation(sources)
111103
assert fe.method == method
112104
assert len(fe.sources) == nsources

0 commit comments

Comments
 (0)