@@ -241,3 +241,52 @@ def test_cwd_cached(tmpdir):
241
241
oldcwd = config .cwd
242
242
tmpdir .chdir ()
243
243
assert config .cwd == oldcwd
244
+
245
+
246
+ def test_debug_mode ():
247
+ from ... import logging
248
+
249
+ sofc_config = config .get ('execution' , 'stop_on_first_crash' )
250
+ ruo_config = config .get ('execution' , 'remove_unnecessary_outputs' )
251
+ ki_config = config .get ('execution' , 'keep_inputs' )
252
+ wf_config = config .get ('logging' , 'workflow_level' )
253
+ if_config = config .get ('logging' , 'interface_level' )
254
+ ut_config = config .get ('logging' , 'utils_level' )
255
+
256
+ wf_level = logging .getLogger ('workflow' ).level
257
+ if_level = logging .getLogger ('interface' ).level
258
+ ut_level = logging .getLogger ('utils' ).level
259
+
260
+ config .enable_debug_mode ()
261
+
262
+ # Check config is updated and logging levels, too
263
+ assert config .get ('execution' , 'stop_on_first_crash' ) == 'true'
264
+ assert config .get ('execution' , 'remove_unnecessary_outputs' ) == 'false'
265
+ assert config .get ('execution' , 'keep_inputs' ) == 'true'
266
+ assert config .get ('logging' , 'workflow_level' ) == 'DEBUG'
267
+ assert config .get ('logging' , 'interface_level' ) == 'DEBUG'
268
+ assert config .get ('logging' , 'utils_level' ) == 'DEBUG'
269
+
270
+ assert logging .getLogger ('workflow' ).level == 10
271
+ assert logging .getLogger ('interface' ).level == 10
272
+ assert logging .getLogger ('utils' ).level == 10
273
+
274
+ # Restore config and levels
275
+ config .set ('execution' , 'stop_on_first_crash' , sofc_config )
276
+ config .set ('execution' , 'remove_unnecessary_outputs' , ruo_config )
277
+ config .set ('execution' , 'keep_inputs' , ki_config )
278
+ config .set ('logging' , 'workflow_level' , wf_config )
279
+ config .set ('logging' , 'interface_level' , if_config )
280
+ config .set ('logging' , 'utils_level' , ut_config )
281
+ logging .update_logging (config )
282
+
283
+ assert config .get ('execution' , 'stop_on_first_crash' ) == sofc_config
284
+ assert config .get ('execution' , 'remove_unnecessary_outputs' ) == ruo_config
285
+ assert config .get ('execution' , 'keep_inputs' ) == ki_config
286
+ assert config .get ('logging' , 'workflow_level' ) == wf_config
287
+ assert config .get ('logging' , 'interface_level' ) == if_config
288
+ assert config .get ('logging' , 'utils_level' ) == ut_config
289
+
290
+ assert logging .getLogger ('workflow' ).level == wf_level
291
+ assert logging .getLogger ('interface' ).level == if_level
292
+ assert logging .getLogger ('utils' ).level == ut_level
0 commit comments