diff options
author | Fred Drake <fdrake@acm.org> | 2002-10-25 21:52:00 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2002-10-25 21:52:00 (GMT) |
commit | 0eebd5cef982686b9438b35d4c4ed395f437ff3e (patch) | |
tree | 49c7affd13defeba3e18990e2a9818fd83482aee /Lib/test/test_cfgparser.py | |
parent | 98e3b29b5969b7738c4c2e1e21fea47357ea6aa0 (diff) | |
download | cpython-0eebd5cef982686b9438b35d4c4ed395f437ff3e.zip cpython-0eebd5cef982686b9438b35d4c4ed395f437ff3e.tar.gz cpython-0eebd5cef982686b9438b35d4c4ed395f437ff3e.tar.bz2 |
Implement a safer and more predictable interpolation approach.
Closes SF bug #511737.
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__": |