Skip to content
Snippets Groups Projects
Commit 378f7bbc authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Test invalid image file

parent 678438c7
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,8 @@ import glob
import numpy as np
import nibabel as nib
from nibabel.spatialimages import HeaderDataError
import fsl.data.constants as constants
import fsl.data.image as fslimage
import fsl.utils.path as fslpath
......@@ -44,18 +46,19 @@ def test_load(testdir):
'ambiguous.img',
'ambiguous.hdr.gz',
'ambiguous.img.gz']
shouldRaise = ['notexist',
'notexist.nii.gz',
'ambiguous']
shouldRaise = [('notexist', fslpath.PathError),
('notexist.nii.gz', fslpath.PathError),
('ambiguous', fslpath.PathError),
('notnifti', HeaderDataError),
('notnifti.nii.gz', HeaderDataError)]
# Not raising an error means the test passes
for fname in shouldPass:
fslimage.Image(op.join(testdir, 'nifti_formats', fname))
# These should raise an error
for fname in shouldRaise:
with pytest.raises(fslpath.PathError):
print fname
for fname, exc in shouldRaise:
with pytest.raises(exc):
fslimage.Image(op.join(testdir, 'nifti_formats', fname))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment