File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -654,6 +654,29 @@ def test_missing_envs(self):
654
654
self .assertEqual (self .config .section1 .value1 (), '${CONFIG_TEST_ENV}' )
655
655
self .assertEqual (self .config .section1 .value2 (), '${CONFIG_TEST_PATH}/path' )
656
656
657
+ def test_default_values (self ):
658
+ os .environ ['DEFINED' ] = 'defined'
659
+ self .addCleanup (os .environ .pop , 'DEFINED' )
660
+
661
+ with open (self .config_file , 'w' ) as config_file :
662
+ config_file .write (
663
+ '[section]\n '
664
+ 'defined_with_default=${DEFINED:default}\n '
665
+ 'undefined_with_default=${UNDEFINED:default}\n '
666
+ 'complex=${DEFINED}/path/${DEFINED:default}/${UNDEFINED}/${UNDEFINED:default}\n '
667
+ )
668
+
669
+ self .config .from_ini (self .config_file )
670
+
671
+ self .assertEqual (
672
+ self .config .section (),
673
+ {
674
+ 'defined_with_default' : 'defined' ,
675
+ 'undefined_with_default' : 'default' ,
676
+ 'complex' : 'defined/path/defined/${UNDEFINED}/default' ,
677
+ },
678
+ )
679
+
657
680
658
681
class ConfigFromYamlTests (unittest .TestCase ):
659
682
You can’t perform that action at this time.
0 commit comments