Skip to content

Commit f8cea61

Browse files
author
Shoshana Berleant
committed
set up mocks
1 parent 5464902 commit f8cea61

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

nipype/workflows/rsfmri/fsl/tests/test_resting.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33

4-
from nipype.testing import (assert_equal, assert_true, assert_almost_equal,
5-
skipif, utils)
6-
from nipype.workflows.rsfmri.fsl import resting
4+
from .....testing import (assert_equal, assert_true, assert_almost_equal,
5+
skipif, utils)
6+
from .....interfaces import fsl
7+
8+
from ..resting import create_resting_preproc
79

810
import unittest
911
import mock
12+
from mock import MagicMock
1013
import nibabel as nb
1114
import numpy as np
1215
import os
1316

17+
def mock_node_factory(*args, **kwargs):
18+
mock = MagicMock()
19+
mock.name = kwargs['name'] if 'name' in kwargs.keys() else ''
20+
if 'interface' in kwargs.keys():
21+
mock = mock.create_autospec(kwargs['interface'], instance=True)
22+
mock.iterables = None
23+
return mock
24+
1425
class TestResting(unittest.TestCase):
1526

1627
in_filenames = {
@@ -27,11 +38,15 @@ def setUp(self):
2738
utils.save_toy_nii(self.fake_data, self.in_filenames['in_file'])
2839

2940
@skipif(True)
30-
def test_create_resting_preproc(self):
41+
@mock.patch('nipype.pipeline.engine.Workflow._write_report_info')
42+
@mock.patch('nipype.workflows.rsfmri.fsl.resting.create_realign_flow',
43+
side_effect=mock_node_factory)
44+
@mock.patch('nipype.pipeline.engine.Node', side_effect=mock_node_factory)
45+
def test_create_resting_preproc(self, mock_Node, mock_realign_wf, nothing):
3146
# setup
3247
print(np.random.randint(0, 10, (2, 2, 2, 5)))
3348
# run
34-
wf = resting.create_resting_preproc()
49+
wf = create_resting_preproc()
3550
wf.run()
3651

3752
# assert

0 commit comments

Comments
 (0)