summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cfgparser.py
diff options
context:
space:
mode:
authorŁukasz Langa <lukasz@langa.pl>2011-04-28 15:03:45 (GMT)
committerŁukasz Langa <lukasz@langa.pl>2011-04-28 15:03:45 (GMT)
commit1aa422fe8f056fd0000da45a67d875adc75cf034 (patch)
treec0682c6861b6630d6daa86a951852aee3d6e1c09 /Lib/test/test_cfgparser.py
parentf53111339779011df6337a69fcd119644f0500b4 (diff)
downloadcpython-1aa422fe8f056fd0000da45a67d875adc75cf034.zip
cpython-1aa422fe8f056fd0000da45a67d875adc75cf034.tar.gz
cpython-1aa422fe8f056fd0000da45a67d875adc75cf034.tar.bz2
Closes #11324: ConfigParser(interpolation=None) doesn't work.
Initial patches by Tobias Brink. Thanks!
Diffstat (limited to 'Lib/test/test_cfgparser.py')
-rw-r--r--Lib/test/test_cfgparser.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py
index 299f37a..a712b2b 100644
--- a/Lib/test/test_cfgparser.py
+++ b/Lib/test/test_cfgparser.py
@@ -864,6 +864,43 @@ class ConfigParserTestCase(BasicTestCase):
cf = self.newconfig()
self.assertRaises(ValueError, cf.add_section, self.default_section)
+
+class ConfigParserTestCaseNoInterpolation(BasicTestCase):
+ config_class = configparser.ConfigParser
+ interpolation = None
+ ini = textwrap.dedent("""
+ [numbers]
+ one = 1
+ two = %(one)s * 2
+ three = ${common:one} * 3
+
+ [hexen]
+ sixteen = ${numbers:two} * 8
+ """).strip()
+
+ def assertMatchesIni(self, cf):
+ self.assertEqual(cf['numbers']['one'], '1')
+ self.assertEqual(cf['numbers']['two'], '%(one)s * 2')
+ self.assertEqual(cf['numbers']['three'], '${common:one} * 3')
+ self.assertEqual(cf['hexen']['sixteen'], '${numbers:two} * 8')
+
+ def test_no_interpolation(self):
+ cf = self.fromstring(self.ini)
+ self.assertMatchesIni(cf)
+
+ def test_empty_case(self):
+ cf = self.newconfig()
+ self.assertIsNone(cf.read_string(""))
+
+ def test_none_as_default_interpolation(self):
+ class CustomConfigParser(configparser.ConfigParser):
+ _DEFAULT_INTERPOLATION = None
+
+ cf = CustomConfigParser()
+ cf.read_string(self.ini)
+ self.assertMatchesIni(cf)
+
+
class ConfigParserTestCaseLegacyInterpolation(ConfigParserTestCase):
config_class = configparser.ConfigParser
interpolation = configparser.LegacyInterpolation()
@@ -1444,6 +1481,7 @@ def test_main():
ConfigParserTestCaseNoValue,
ConfigParserTestCaseExtendedInterpolation,
ConfigParserTestCaseLegacyInterpolation,
+ ConfigParserTestCaseNoInterpolation,
ConfigParserTestCaseTrickyFile,
MultilineValuesTestCase,
RawConfigParserTestCase,