@@ -864,6 +864,43 @@ def test_add_section_default(self):
864864 cf = self .newconfig ()
865865 self .assertRaises (ValueError , cf .add_section , self .default_section )
866866
867+
868+ class ConfigParserTestCaseNoInterpolation (BasicTestCase ):
869+ config_class = configparser .ConfigParser
870+ interpolation = None
871+ ini = textwrap .dedent ("""
872+ [numbers]
873+ one = 1
874+ two = %(one)s * 2
875+ three = ${common:one} * 3
876+
877+ [hexen]
878+ sixteen = ${numbers:two} * 8
879+ """ ).strip ()
880+
881+ def assertMatchesIni (self , cf ):
882+ self .assertEqual (cf ['numbers' ]['one' ], '1' )
883+ self .assertEqual (cf ['numbers' ]['two' ], '%(one)s * 2' )
884+ self .assertEqual (cf ['numbers' ]['three' ], '${common:one} * 3' )
885+ self .assertEqual (cf ['hexen' ]['sixteen' ], '${numbers:two} * 8' )
886+
887+ def test_no_interpolation (self ):
888+ cf = self .fromstring (self .ini )
889+ self .assertMatchesIni (cf )
890+
891+ def test_empty_case (self ):
892+ cf = self .newconfig ()
893+ self .assertIsNone (cf .read_string ("" ))
894+
895+ def test_none_as_default_interpolation (self ):
896+ class CustomConfigParser (configparser .ConfigParser ):
897+ _DEFAULT_INTERPOLATION = None
898+
899+ cf = CustomConfigParser ()
900+ cf .read_string (self .ini )
901+ self .assertMatchesIni (cf )
902+
903+
867904class ConfigParserTestCaseLegacyInterpolation (ConfigParserTestCase ):
868905 config_class = configparser .ConfigParser
869906 interpolation = configparser .LegacyInterpolation ()
@@ -1444,6 +1481,7 @@ def test_main():
14441481 ConfigParserTestCaseNoValue ,
14451482 ConfigParserTestCaseExtendedInterpolation ,
14461483 ConfigParserTestCaseLegacyInterpolation ,
1484+ ConfigParserTestCaseNoInterpolation ,
14471485 ConfigParserTestCaseTrickyFile ,
14481486 MultilineValuesTestCase ,
14491487 RawConfigParserTestCase ,
0 commit comments