Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv25460/Lib/test Modified Files: test_cfgparser.py Log Message: Implement a safer and more predictable interpolation approach. Closes SF bug #511737. Index: test_cfgparser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cfgparser.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** test_cfgparser.py 25 Oct 2002 20:42:44 -0000 1.17 --- test_cfgparser.py 25 Oct 2002 21:52:00 -0000 1.18 *************** *** 290,297 **** def test_main(): suite = unittest.TestSuite() suite.addTests([unittest.makeSuite(ConfigParserTestCase), ! unittest.makeSuite(RawConfigParserTestCase)]) test_support.run_suite(suite) --- 290,312 ---- + 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(SafeConfigParserTestCase)]) test_support.run_suite(suite)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4