@@ -419,8 +419,10 @@ def test_class_instantiate(
419
419
recursive : bool ,
420
420
) -> Any :
421
421
passthrough ["_recursive_" ] = recursive
422
+ original_config_str = str (config )
422
423
obj = instantiate_func (config , ** passthrough )
423
424
assert partial_equal (obj , expected )
425
+ assert str (config ) == original_config_str
424
426
425
427
426
428
def test_partial_with_missing (instantiate_func : Any ) -> Any :
@@ -431,10 +433,12 @@ def test_partial_with_missing(instantiate_func: Any) -> Any:
431
433
"b" : 20 ,
432
434
"c" : 30 ,
433
435
}
436
+ original_config_str = str (config )
434
437
partial_obj = instantiate_func (config )
435
438
assert partial_equal (partial_obj , partial (AClass , b = 20 , c = 30 ))
436
439
obj = partial_obj (a = 10 )
437
440
assert partial_equal (obj , AClass (a = 10 , b = 20 , c = 30 ))
441
+ assert str (config ) == original_config_str
438
442
439
443
440
444
def test_instantiate_with_missing (instantiate_func : Any ) -> Any :
@@ -468,6 +472,7 @@ def test_none_cases(
468
472
ListConfig (None ),
469
473
],
470
474
}
475
+ original_config_str = str (cfg )
471
476
ret = instantiate_func (cfg )
472
477
assert ret .kwargs ["none_dict" ] is None
473
478
assert ret .kwargs ["none_list" ] is None
@@ -477,6 +482,7 @@ def test_none_cases(
477
482
assert ret .kwargs ["list" ][0 ] == 10
478
483
assert ret .kwargs ["list" ][1 ] is None
479
484
assert ret .kwargs ["list" ][2 ] is None
485
+ assert str (cfg ) == original_config_str
480
486
481
487
482
488
@mark .parametrize (
@@ -537,6 +543,20 @@ def test_none_cases(
537
543
6 ,
538
544
id = "interpolation_from_recursive" ,
539
545
),
546
+ param (
547
+ {
548
+ "my_id" : 5 ,
549
+ "node" : {
550
+ "b" : "${foo_b}" ,
551
+ },
552
+ "foo_b" : {
553
+ "unique_id" : "${my_id}" ,
554
+ },
555
+ },
556
+ {},
557
+ OmegaConf .create ({"b" : {"unique_id" : 5 }}),
558
+ id = "interpolation_from_parent_with_interpolation" ,
559
+ ),
540
560
],
541
561
)
542
562
def test_interpolation_accessing_parent (
@@ -547,12 +567,14 @@ def test_interpolation_accessing_parent(
547
567
) -> Any :
548
568
cfg_copy = OmegaConf .create (input_conf )
549
569
input_conf = OmegaConf .create (input_conf )
570
+ original_config_str = str (input_conf )
550
571
obj = instantiate_func (input_conf .node , ** passthrough )
551
572
if isinstance (expected , partial ):
552
573
assert partial_equal (obj , expected )
553
574
else :
554
575
assert obj == expected
555
576
assert input_conf == cfg_copy
577
+ assert str (input_conf ) == original_config_str
556
578
557
579
558
580
@mark .parametrize (
0 commit comments