@@ -781,17 +781,20 @@ def setUp(self):
781
781
self .config = providers .Configuration (name = 'config' )
782
782
783
783
os .environ ['CONFIG_TEST_ENV' ] = 'test-value'
784
+ os .environ ['CONFIG_TEST_PATH' ] = 'test-path'
784
785
785
786
_ , self .config_file = tempfile .mkstemp ()
786
787
with open (self .config_file , 'w' ) as config_file :
787
788
config_file .write (
788
789
'section1:\n '
789
790
' value1: ${CONFIG_TEST_ENV}\n '
791
+ ' value2: ${CONFIG_TEST_PATH}/path\n '
790
792
)
791
793
792
794
def tearDown (self ):
793
795
del self .config
794
796
del os .environ ['CONFIG_TEST_ENV' ]
797
+ del os .environ ['CONFIG_TEST_PATH' ]
795
798
os .unlink (self .config_file )
796
799
797
800
@unittest .skipIf (sys .version_info [:2 ] == (3 , 4 ), 'PyYAML does not support Python 3.4' )
@@ -803,11 +806,19 @@ def test_env_variable_interpolation(self):
803
806
{
804
807
'section1' : {
805
808
'value1' : 'test-value' ,
809
+ 'value2' : 'test-path/path' ,
806
810
},
807
811
},
808
812
)
809
- self .assertEqual (self .config .section1 (), {'value1' : 'test-value' })
813
+ self .assertEqual (
814
+ self .config .section1 (),
815
+ {
816
+ 'value1' : 'test-value' ,
817
+ 'value2' : 'test-path/path' ,
818
+ },
819
+ )
810
820
self .assertEqual (self .config .section1 .value1 (), 'test-value' )
821
+ self .assertEqual (self .config .section1 .value2 (), 'test-path/path' )
811
822
812
823
@unittest .skipIf (sys .version_info [:2 ] == (3 , 4 ), 'PyYAML does not support Python 3.4' )
813
824
def test_option_env_variable_interpolation (self ):
@@ -818,41 +829,47 @@ def test_option_env_variable_interpolation(self):
818
829
{
819
830
'section1' : {
820
831
'value1' : 'test-value' ,
832
+ 'value2' : 'test-path/path' ,
821
833
},
822
834
},
823
835
)
824
- self .assertEqual (self .config .option .section1 (), {'value1' : 'test-value' })
836
+ self .assertEqual (
837
+ self .config .option .section1 (),
838
+ {
839
+ 'value1' : 'test-value' ,
840
+ 'value2' : 'test-path/path' ,
841
+ },
842
+ )
825
843
self .assertEqual (self .config .option .section1 .value1 (), 'test-value' )
844
+ self .assertEqual (self .config .option .section1 .value2 (), 'test-path/path' )
826
845
827
846
@unittest .skipIf (sys .version_info [:2 ] == (3 , 4 ), 'PyYAML does not support Python 3.4' )
828
847
def test_env_variable_interpolation_custom_loader (self ):
829
848
self .config .from_yaml (self .config_file , loader = yaml .UnsafeLoader )
830
849
831
850
self .assertEqual (
832
- self .config (),
851
+ self .config . section1 (),
833
852
{
834
- 'section1' : {
835
- 'value1' : 'test-value' ,
836
- },
853
+ 'value1' : 'test-value' ,
854
+ 'value2' : 'test-path/path' ,
837
855
},
838
856
)
839
- self .assertEqual (self .config .section1 (), {'value1' : 'test-value' })
840
857
self .assertEqual (self .config .section1 .value1 (), 'test-value' )
858
+ self .assertEqual (self .config .section1 .value2 (), 'test-path/path' )
841
859
842
860
@unittest .skipIf (sys .version_info [:2 ] == (3 , 4 ), 'PyYAML does not support Python 3.4' )
843
861
def test_option_env_variable_interpolation_custom_loader (self ):
844
862
self .config .option .from_yaml (self .config_file , loader = yaml .UnsafeLoader )
845
863
846
864
self .assertEqual (
847
- self .config .option (),
865
+ self .config .option . section1 (),
848
866
{
849
- 'section1' : {
850
- 'value1' : 'test-value' ,
851
- },
867
+ 'value1' : 'test-value' ,
868
+ 'value2' : 'test-path/path' ,
852
869
},
853
870
)
854
- self .assertEqual (self .config .option .section1 (), {'value1' : 'test-value' })
855
871
self .assertEqual (self .config .option .section1 .value1 (), 'test-value' )
872
+ self .assertEqual (self .config .option .section1 .value2 (), 'test-path/path' )
856
873
857
874
858
875
class ConfigFromPydanticTests (unittest .TestCase ):
0 commit comments