@@ -461,12 +461,6 @@ def test_BaseInterface_load_save_inputs():
461
461
tmp_dir = tempfile .mkdtemp ()
462
462
tmp_json = os .path .join (tmp_dir , 'settings.json' )
463
463
464
- def _rem_undefined (indict ):
465
- for key , val in list (indict .items ()):
466
- if not nib .isdefined (val ):
467
- indict .pop (key , None )
468
- return indict
469
-
470
464
class InputSpec (nib .TraitedSpec ):
471
465
input1 = nib .traits .Int ()
472
466
input2 = nib .traits .Float ()
@@ -485,14 +479,23 @@ def __init__(self, **inputs):
485
479
bif .save_inputs_to_json (tmp_json )
486
480
bif2 = DerivedInterface ()
487
481
bif2 .load_inputs_from_json (tmp_json )
488
- yield assert_equal , _rem_undefined ( bif2 .inputs .get () ), inputs_dict
482
+ yield assert_equal , bif2 .inputs .get_traitsfree ( ), inputs_dict
489
483
490
484
bif3 = DerivedInterface (from_file = tmp_json )
491
- yield assert_equal , _rem_undefined (bif3 .inputs .get ()), inputs_dict
485
+ yield assert_equal , bif3 .inputs .get_traitsfree (), inputs_dict
486
+
487
+ inputs_dict2 = inputs_dict .copy ()
488
+ inputs_dict2 .update ({'input4' : 'some other string' })
489
+ bif4 = DerivedInterface (from_file = tmp_json , input4 = inputs_dict2 ['input4' ])
490
+ yield assert_equal , bif4 .inputs .get_traitsfree (), inputs_dict2
491
+
492
+ bif5 = DerivedInterface (input4 = inputs_dict2 ['input4' ])
493
+ bif5 .load_inputs_from_json (tmp_json , overwrite = False )
494
+ yield assert_equal , bif5 .inputs .get_traitsfree (), inputs_dict2
492
495
493
- inputs_dict . update ({ 'input4' : 'some other string' } )
494
- bif4 = DerivedInterface ( from_file = tmp_json , input4 = 'some other string' )
495
- yield assert_equal , _rem_undefined ( bif4 .inputs .get () ), inputs_dict
496
+ bif6 = DerivedInterface ( input4 = inputs_dict2 [ 'input4' ] )
497
+ bif6 . load_inputs_from_json ( tmp_json )
498
+ yield assert_equal , bif6 .inputs .get_traitsfree ( ), inputs_dict
496
499
497
500
def assert_not_raises (fn , * args , ** kwargs ):
498
501
fn (* args , ** kwargs )
0 commit comments