@@ -72,28 +72,28 @@ def test_plugin_defaults(workflow, caplog):
72
72
def test_plugin_args_noconfig (workflow , caplog ):
73
73
"""Test the plugin works with typical nipype arguments."""
74
74
caplog .set_level (logging .CRITICAL , logger = "nipype.workflow" )
75
- workflow .run (
76
- plugin = MultiProcPlugin (),
77
- plugin_args = {"n_procs" : 2 , "memory_gb" : 0.1 },
78
- )
75
+ workflow .run (plugin = MultiProcPlugin (plugin_args = {"n_procs" : 2 , "memory_gb" : 0.1 }))
76
+
79
77
78
+ def touch_file (file_path ):
79
+ """Module-level functions play more nicely with multiprocessing."""
80
+ with open (file_path , "w" ) as f :
81
+ f .write ("flag" )
80
82
81
- def test_plugin_app_config (workflow , caplog , capsys ):
83
+
84
+ def test_plugin_app_config (tmp_path , workflow , caplog ):
82
85
"""Test the plugin works with a nipreps-style configuration."""
83
86
84
- def init_print ():
85
- print ("Custom init" )
87
+ init_flag = tmp_path / "init_flag.txt"
86
88
87
89
app_config = SimpleNamespace (
88
- environment = SimpleNamespace (total_memory_gb = 1 ),
89
- _process_initializer = init_print () ,
90
- file_path = '/does/not/need/to/exist/for/testing' ,
90
+ environment = SimpleNamespace (total_memory = 1 ),
91
+ _process_initializer = touch_file ,
92
+ file_path = init_flag ,
91
93
)
92
- caplog .set_level (logging .CRITICAL , logger = "nipype.workflow" )
94
+ caplog .set_level (logging .INFO , logger = "nipype.workflow" )
93
95
workflow .run (
94
- plugin = MultiProcPlugin (),
95
- plugin_args = {"n_procs" : 2 , "app_config" : app_config },
96
+ plugin = MultiProcPlugin (plugin_args = {"n_procs" : 2 , "app_config" : app_config })
96
97
)
97
98
98
- captured = capsys .readouterr ()
99
- assert "Custom init" in captured .out
99
+ assert init_flag .exists () and init_flag .read_text () == "flag"
0 commit comments