diff options
Diffstat (limited to 'Lib/test/test_cfgparser.py')
-rw-r--r-- | Lib/test/test_cfgparser.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py index 6d93c61..b221598 100644 --- a/Lib/test/test_cfgparser.py +++ b/Lib/test/test_cfgparser.py @@ -289,10 +289,25 @@ class RawConfigParserTestCase(TestCaseBase): ('name', 'value')]) +class SafeConfigParserTestCase(ConfigParserTestCase): + config_class = ConfigParser.SafeConfigParser + + def test_safe_interpolation(self): + # See http://www.python.org/sf/511737 + cf = self.fromstring("[section]\n" + "option1=xxx\n" + "option2=%(option1)s/xxx\n" + "ok=%(option1)s/%%s\n" + "not_ok=%(option2)s/%%s") + self.assertEqual(cf.get("section", "ok"), "xxx/%s") + self.assertEqual(cf.get("section", "not_ok"), "xxx/xxx/%s") + + def test_main(): suite = unittest.TestSuite() suite.addTests([unittest.makeSuite(ConfigParserTestCase), - unittest.makeSuite(RawConfigParserTestCase)]) + unittest.makeSuite(RawConfigParserTestCase), + unittest.makeSuite(SafeConfigParserTestCase)]) test_support.run_suite(suite) if __name__ == "__main__": |