From 1ab49ce6363a2ed8aef460e55fbdacc1e01405c4 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Wed, 28 Feb 2018 10:10:28 +0000 Subject: [PATCH] unit tests for ensure module --- tests/test_ensure.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/test_ensure.py diff --git a/tests/test_ensure.py b/tests/test_ensure.py new file mode 100644 index 000000000..dabd3a952 --- /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()) -- GitLab