Skip to content

Commit 8ada360

Browse files
committed
ensure node crashes switch back directory
1 parent 49d1a95 commit 8ada360

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

nipype/pipeline/engine/tests/test_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,40 +338,41 @@ def test_provenance(tmpdir):
338338
assert len(psg.bundles) == 2
339339
assert len(psg.get_records()) == 7
340340

341-
342341
def test_mapnode_crash(tmpdir):
343342
"""Test mapnode crash when stop_on_first_crash is True"""
343+
cwd = os.getcwd()
344344
def myfunction(string):
345345
return string + 'meh'
346346
node = pe.MapNode(niu.Function(input_names=['WRONG'],
347347
output_names=['newstring'],
348348
function=myfunction),
349349
iterfield=['WRONG'],
350350
name='myfunc')
351-
352351
node.inputs.WRONG = ['string' + str(i) for i in range(3)]
353352
node.config = deepcopy(config._sections)
354353
node.config['execution']['stop_on_first_crash'] = True
355354
node.base_dir = str(tmpdir)
356355
with pytest.raises(TypeError):
357356
node.run()
358-
357+
os.chdir(cwd)
359358

360359
def test_mapnode_crash2(tmpdir):
361360
"""Test mapnode crash when stop_on_first_crash is False"""
361+
cwd = os.getcwd()
362362
def myfunction(string):
363363
return string + 'meh'
364+
364365
node = pe.MapNode(niu.Function(input_names=['WRONG'],
365366
output_names=['newstring'],
366367
function=myfunction),
367368
iterfield=['WRONG'],
368369
name='myfunc')
369-
370370
node.inputs.WRONG = ['string' + str(i) for i in range(3)]
371371
node.base_dir = str(tmpdir)
372372

373373
with pytest.raises(Exception):
374374
node.run()
375+
os.chdir(cwd)
375376

376377

377378
def test_mapnode_crash3(tmpdir):
@@ -384,7 +385,6 @@ def myfunction(string):
384385
function=myfunction),
385386
iterfield=['WRONG'],
386387
name='myfunc')
387-
388388
node.inputs.WRONG = ['string' + str(i) for i in range(3)]
389389
wf = pe.Workflow('testmapnodecrash')
390390
wf.add_nodes([node])

0 commit comments

Comments
 (0)