diff --git a/tests/test_ensure.py b/tests/test_ensure.py new file mode 100644 index 0000000000000000000000000000000000000000..dabd3a952f22e037d202d251c5c6d18c14a2fe31 --- /dev/null +++ b/tests/test_ensure.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# +# test_ensure.py - +# +# Author: Paul McCarthy <pauldmccarthy@gmail.com> +# + + +import numpy as np +import nibabel as nib + +import fsl.utils.tempdir as tempdir +import fsl.utils.ensure as ensure + +from . import make_random_image + + +def test_ensureIsImage(): + + with tempdir.tempdir(): + img = make_random_image('image.nii') + + assert ensure.ensureIsImage(img) is img + + loaded = ensure.ensureIsImage('image.nii') + + assert isinstance(loaded, nib.nifti1.Nifti1Image) + assert np.all(img.get_data() == loaded.get_data())