Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJaeger committed Sep 12, 2024
1 parent dd8be94 commit 094f115
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Folders to ignore
.coverage
.coverage*
.idea/
__pycache__/
.ipynb_checkpoints/
Expand Down
1 change: 0 additions & 1 deletion tests/test_fitting_dwipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ def test_dwi_constraints_success(constraints):
shape = (60, 22)
elif sum(constraints) == 3:
shape = (90, 22)
print(np.shape(val))
assert val.dtype == np.float64
assert np.shape(val) == shape

Expand Down
8 changes: 4 additions & 4 deletions tests/test_preprocessing_mrpreproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from conftest import load_data

from pydesigner.preprocessing import mrpreproc, mrinfoutil
from pydesigner.system.errors import MRTrixError
from pydesigner.system.errors import FileExtensionError, MRTrixError

DATA = load_data(type="hifi")
PATH_DWI = DATA["nifti"]
Expand Down Expand Up @@ -198,13 +198,13 @@ def test_denoise_output_success(tmp_path, nthreads, force, verbose):

def test_degibbs_output_failure(tmp_path):
"""Test whether function `degibbs` fails when return code is non-zero"""
output_nii = str(tmp_path / "output.nii")
output_mif = str(tmp_path / "output.mif")
with patch("subprocess.run") as mock_subprocess:
mock_subprocess.return_value = MagicMock(
returncode=1, stderr="stderr"
)
with pytest.raises(MRTrixError) as exc:
mrpreproc.degibbs(PATH_DWI, output_nii)
mrpreproc.degibbs(PATH_MIF, output_mif)
assert f"Mrdegibbs failed" in str(exc.value)
assert "stderr" in str(exc.value)

Expand All @@ -222,7 +222,7 @@ def test_degibbs_output_failure(tmp_path):
def test_degibbs_output_success(tmp_path, nthreads, force, verbose):
"""Test whether function `degibbs` fails when return code is non-zero"""
output_mif = str(tmp_path / "output.mif")
mrpreproc.degibbs(PATH_DWI, output_mif, nthreads=nthreads, force=force, verbose=verbose)
mrpreproc.degibbs(PATH_MIF, output_mif, nthreads=nthreads, force=force, verbose=verbose)
assert os.path.exists(output_mif)
assert mrinfoutil.format(output_mif) == "MRtrix"
mrinfoutil.size(output_mif) == (2, 2, 2, 337)
Expand Down

0 comments on commit 094f115

Please sign in to comment.