From a37f8d9eefbb90d5f18c23701c2257706b61e984 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauld.mccarthy@gmail.com>
Date: Fri, 19 May 2017 13:04:26 +0100
Subject: [PATCH] Gargh, missed some calls

---
 tests/test_callfsl.py | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/tests/test_callfsl.py b/tests/test_callfsl.py
index 6d20201a6..e137160e4 100644
--- a/tests/test_callfsl.py
+++ b/tests/test_callfsl.py
@@ -28,7 +28,11 @@ def setup_module():
 
 # mock subprocess.check_output command
 # which expects 'fslstats -m filename'
+# or 'fslinfo ...'
 def mock_check_output(args):
+    if args[0].endswith('fslinfo'):
+        return 'info'
+
     img = nib.load(args[-2])
     return str(img.get_data().mean())
 
@@ -49,11 +53,11 @@ def test_callfsl():
                         mock_check_output):
             result = callfsl.callFSL(cmd)
 
-        assert np.isclose(float(result), img.mean())
+            assert np.isclose(float(result), img.mean())
 
-        # Or pass a list of args
-        result = callfsl.callFSL(*cmd.split())
-        assert np.isclose(float(result), img.mean())
+            # Or pass a list of args
+            result = callfsl.callFSL(*cmd.split())
+            assert np.isclose(float(result), img.mean())
 
         # Bad commands
         badcmds = ['fslblob', 'fslstats notafile']
@@ -64,7 +68,9 @@ def test_callfsl():
 
         # No FSL - should crash
         cmd = 'fslinfo {}'.format(fname)
-        callfsl.callFSL(cmd)
+        with mock.patch('fsl.utils.callfsl.sp.check_output',
+                        mock_check_output):
+            callfsl.callFSL(cmd)
         fslplatform.fsldir = None
         with pytest.raises(Exception):
             callfsl.callFSL(cmd)
-- 
GitLab