From 6e69cc4467306e784099856e202bc6d7e6ec8181 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Sat, 3 Mar 2018 19:06:07 +0000 Subject: [PATCH] Test chaining fileorthing decorators --- tests/test_wrapperutils.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_wrapperutils.py b/tests/test_wrapperutils.py index 77029e73a..658909ae9 100644 --- a/tests/test_wrapperutils.py +++ b/tests/test_wrapperutils.py @@ -270,3 +270,24 @@ def test_fileOrImage(): # array array array result = func(img1, img2=img2, output=wutils.LOAD)['output'] assert np.all(result.get_data() == expected) + + +def test_chained_fileOrImageAndArray(): + @wutils.fileOrImage('image') + @wutils.fileOrArray('array') + def func(image, array): + nib.load(image) + np.loadtxt(array) + + image = nib.nifti1.Nifti1Image(np.array([[1, 2], [ 3, 4]]), np.eye(4)) + array = np.array([[5, 6, 7, 8]]) + + with tempdir.tempdir(): + + nib.save(image, 'image.nii') + np.savetxt('array.txt', array) + + func('image.nii', 'array.txt') + func('image.nii', array) + func( image, 'array.txt') + func( image, array) -- GitLab