Skip to content

Commit cc37791

Browse files
author
dmordom
committed
Added mapnode single input test
Updated deprecated "workflow.config['crashdump_dir']" to "workflow.config['execution']['crashdump_dir']" in other tests in test_engine.py
1 parent 6e32e6b commit cc37791

File tree

1 file changed

+55
-2
lines changed

1 file changed

+55
-2
lines changed

nipype/pipeline/tests/test_engine.py

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def func2(a):
551551
w1.connect(n1, ('a', modify), n2,'a')
552552
w1.base_dir = wd
553553

554-
w1.config = {'crashdump_dir': wd}
554+
w1.config['execution']['crashdump_dir'] = wd
555555
# generate outputs
556556
error_raised = False
557557
try:
@@ -581,7 +581,7 @@ def func1(in1):
581581
n1.inputs.in1 = [1]
582582
w1 = Workflow(name='test')
583583
w1.base_dir = wd
584-
w1.config = {'crashdump_dir': wd}
584+
w1.config['execution']['crashdump_dir'] = wd
585585
w1.add_nodes([n1])
586586
w1.run()
587587
n1.inputs.in1 = [2]
@@ -606,3 +606,56 @@ def func1(in1):
606606
yield assert_false, error_raised
607607
os.chdir(cwd)
608608
rmtree(wd)
609+
610+
def test_serial_input():
611+
cwd = os.getcwd()
612+
wd = mkdtemp()
613+
os.chdir(wd)
614+
from nipype import MapNode, Function, Workflow
615+
def func1(in1):
616+
return in1
617+
n1 = MapNode(Function(input_names=['in1'],
618+
output_names=['out'],
619+
function=func1),
620+
iterfield=['in1'],
621+
name='n1')
622+
n1.inputs.in1 = [1,2,3]
623+
624+
625+
w1 = Workflow(name='test')
626+
w1.base_dir = wd
627+
w1.add_nodes([n1])
628+
# set local check
629+
w1.config['execution'] = {'stop_on_first_crash': 'true',
630+
'local_hash_check': 'true',
631+
'crashdump_dir': wd}
632+
633+
# test output of num_subnodes method when serial is default (False)
634+
num_subnodes_default = n1.num_subnodes()
635+
yield assert_equal, num_subnodes_default, len(n1.inputs.in1)
636+
637+
# test running the workflow on default conditions
638+
error_raised = False
639+
try:
640+
w1.run(plugin='MultiProc')
641+
except Exception, e:
642+
pe.logger.info('Exception: %s' % str(e))
643+
error_raised = True
644+
yield assert_false, error_raised
645+
646+
# test output of num_subnodes method when serial is True
647+
n1._serial=True
648+
num_subnodes_serial = n1.num_subnodes()
649+
yield assert_equal, num_subnodes_serial, 1
650+
651+
# test running the workflow on serial conditions
652+
error_raised = False
653+
try:
654+
w1.run(plugin='MultiProc')
655+
except Exception, e:
656+
pe.logger.info('Exception: %s' % str(e))
657+
error_raised = True
658+
yield assert_false, error_raised
659+
660+
os.chdir(cwd)
661+
rmtree(wd)

0 commit comments

Comments
 (0)