summaryrefslogtreecommitdiff
path: root/Lib/test/test_cfgparser.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-03-13 17:43:32 +0000
committerGeorg Brandl <georg@python.org>2007-03-13 17:43:32 +0000
commit92a6baed7bfae3eaad31c47c5d80348b05a62d8c (patch)
tree51eacc5dcf468824ec0c8d44eee1b8cb3f8a80ff /Lib/test/test_cfgparser.py
parenta36cde4ccc24a90604899ea9d25d273a2c92c87c (diff)
downloadcpython-git-92a6baed7bfae3eaad31c47c5d80348b05a62d8c.tar.gz
Patch #1603688: ConfigParser.SafeConfigParser now checks values that
are set for invalid interpolation sequences that would lead to errors on reading back those values.
Diffstat (limited to 'Lib/test/test_cfgparser.py')
-rw-r--r--Lib/test/test_cfgparser.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py
index 9e3b495c5a..c4df74185e 100644
--- a/Lib/test/test_cfgparser.py
+++ b/Lib/test/test_cfgparser.py
@@ -422,6 +422,18 @@ class SafeConfigParserTestCase(ConfigParserTestCase):
self.assertEqual(cf.get("section", "ok"), "xxx/%s")
self.assertEqual(cf.get("section", "not_ok"), "xxx/xxx/%s")
+ def test_set_malformatted_interpolation(self):
+ cf = self.fromstring("[sect]\n"
+ "option1=foo\n")
+
+ self.assertEqual(cf.get('sect', "option1"), "foo")
+
+ self.assertRaises(ValueError, cf.set, "sect", "option1", "%foo")
+ self.assertRaises(ValueError, cf.set, "sect", "option1", "foo%")
+ self.assertRaises(ValueError, cf.set, "sect", "option1", "f%oo")
+
+ self.assertEqual(cf.get('sect', "option1"), "foo")
+
def test_set_nonstring_types(self):
cf = self.fromstring("[sect]\n"
"option1=foo\n")