@@ -41,7 +41,7 @@ def _check_no_et():
41
41
return et
42
42
43
43
44
- def test_no_et (tmp_path ):
44
+ def test_no_et_bare (tmp_path ):
45
45
from unittest .mock import patch
46
46
from nipype .pipeline import engine as pe
47
47
from nipype .interfaces import utility as niu
@@ -70,42 +70,30 @@ def test_no_et(tmp_path):
70
70
res = wf1 .run ()
71
71
assert next (iter (res .nodes )).result .outputs .out == et
72
72
73
- # MultiProc run - environment initialized with NIPYPE_NO_ET
74
- wf2 = pe .Workflow (name = "wf2" , base_dir = str (tmp_path ))
75
- wf2 .add_nodes ([pe .Node (niu .Function (function = _check_no_et ), name = "n" )])
76
- res = wf2 .run (plugin = "MultiProc" , plugin_args = {"n_procs" : 1 })
77
- assert next (iter (res .nodes )).result .outputs .out is False
78
-
79
- # LegacyMultiProc run - environment initialized with NIPYPE_NO_ET
80
- wf3 = pe .Workflow (name = "wf3" , base_dir = str (tmp_path ))
81
- wf3 .add_nodes ([pe .Node (niu .Function (function = _check_no_et ), name = "n" )])
82
- res = wf3 .run (plugin = "LegacyMultiProc" , plugin_args = {"n_procs" : 1 })
83
- assert next (iter (res .nodes )).result .outputs .out is False
84
-
85
- # run_without_submitting - environment not set
86
- wf4 = pe .Workflow (name = "wf4" , base_dir = str (tmp_path ))
87
- wf4 .add_nodes (
88
- [
89
- pe .Node (
90
- niu .Function (function = _check_no_et ),
91
- run_without_submitting = True ,
92
- name = "n" ,
93
- )
94
- ]
95
- )
96
- res = wf4 .run (plugin = "MultiProc" , plugin_args = {"n_procs" : 1 })
97
- assert next (iter (res .nodes )).result .outputs .out == et
98
73
99
- # run_without_submitting - environment not set
100
- wf5 = pe .Workflow (name = "wf5" , base_dir = str (tmp_path ))
101
- wf5 .add_nodes (
102
- [
103
- pe .Node (
104
- niu .Function (function = _check_no_et ),
105
- run_without_submitting = True ,
106
- name = "n" ,
107
- )
108
- ]
74
+ @pytest .mark .parametrize ("plugin" , ("MultiProc" , "LegacyMultiProc" ))
75
+ @pytest .mark .parametrize ("run_without_submitting" , (True , False ))
76
+ def test_no_et_multiproc (tmp_path , plugin , run_without_submitting ):
77
+ from unittest .mock import patch
78
+ from nipype .pipeline import engine as pe
79
+ from nipype .interfaces import utility as niu
80
+ from nipype .interfaces .base import BaseInterface
81
+
82
+ et = os .getenv ("NIPYPE_NO_ET" ) is None
83
+
84
+ # Multiprocessing runs initialize new processes with NIPYPE_NO_ET
85
+ # This does not apply to unsubmitted jobs, run by the main thread
86
+ expectation = et if run_without_submitting else False
87
+
88
+ # Pytest doesn't trigger this, so let's pretend it's there
89
+ with patch .object (BaseInterface , "_etelemetry_version_data" , {}):
90
+
91
+ wf = pe .Workflow (name = "wf2" , base_dir = str (tmp_path ))
92
+ n = pe .Node (
93
+ niu .Function (function = _check_no_et ),
94
+ run_without_submitting = run_without_submitting ,
95
+ name = "n" ,
109
96
)
110
- res = wf5 .run (plugin = "LegacyMultiProc" , plugin_args = {"n_procs" : 1 })
111
- assert next (iter (res .nodes )).result .outputs .out == et
97
+ wf .add_nodes ([n ])
98
+ res = wf .run (plugin = plugin , plugin_args = {"n_procs" : 1 })
99
+ assert next (iter (res .nodes )).result .outputs .out is expectation
0 commit comments