diff --git a/nipype/conftest.py b/nipype/conftest.py index b099fd0078..52b2f84c49 100644 --- a/nipype/conftest.py +++ b/nipype/conftest.py @@ -12,7 +12,6 @@ data_dir = os.path.join(temp_folder, "data") shutil.copytree(NIPYPE_DATADIR, data_dir) - @pytest.fixture(autouse=True) def add_np(doctest_namespace): doctest_namespace["np"] = numpy diff --git a/nipype/pipeline/plugins/tests/test_base.py b/nipype/pipeline/plugins/tests/test_base.py index fddcfa2368..a1d62ce235 100644 --- a/nipype/pipeline/plugins/tests/test_base.py +++ b/nipype/pipeline/plugins/tests/test_base.py @@ -3,10 +3,11 @@ # vi: set ft=python sts=4 ts=4 sw=4 et: """Tests for the engine module """ +import pytest +from pathlib import Path import numpy as np import scipy.sparse as ssp - def test_scipy_sparse(): foo = ssp.lil_matrix(np.eye(3, k=1)) goo = foo.getrowview(0) @@ -39,3 +40,34 @@ def func(arg1): wf.run(plugin='MultiProc') """ + +@pytest.mark.regression +def test_remove_nodes(tmp_path): + import os + import nipype.interfaces.utility as niu + import nipype.pipeline.engine as pe + + wf = pe.Workflow(name='test') + + def func(arg1): + try: + if arg1 == 2: + raise Exception('arg cannot be ' + str(arg1)) + except: + pass + return arg1 + + funkynode = pe.MapNode(niu.Function(function=func, input_names=['arg1'], + output_names=['out']), + iterfield=['arg1'], + name = 'functor') + funkynode.inputs.arg1 = [1,2] + + wf.add_nodes([funkynode]) + wf.base_dir = tmpdir + wf.config['execution']['remove_node_directories'] = 'true' + wf.config['execution']['stop_on_first_crash'] = 'false' + wf.config['logging']['crashdump_dir'] = str(tmp_path) + res = wf.run(plugin='MultiProc') + + assert not Path.is_dir(tmp_path / "test" / "functor")