diff options
author | Łukasz Langa <lukasz@langa.pl> | 2012-12-31 02:41:54 (GMT) |
---|---|---|
committer | Łukasz Langa <lukasz@langa.pl> | 2012-12-31 02:41:54 (GMT) |
commit | 0dc5ab41f07a26deaebe46f593e572e221772aa2 (patch) | |
tree | 0e3eb3bb0e84366b91d501723ebf10097e10f946 /Lib/test/test_configparser.py | |
parent | 97eefc105ef13e1e6fa1fec39a914d83a751e7c7 (diff) | |
parent | c7ce3f7be5e72cf2253fc997bfdb6c80e27400f8 (diff) | |
download | cpython-0dc5ab41f07a26deaebe46f593e572e221772aa2.zip cpython-0dc5ab41f07a26deaebe46f593e572e221772aa2.tar.gz cpython-0dc5ab41f07a26deaebe46f593e572e221772aa2.tar.bz2 |
Merged `parser.clean()` fix (issue #16820) from 3.2.
Diffstat (limited to 'Lib/test/test_configparser.py')
-rw-r--r-- | Lib/test/test_configparser.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_configparser.py b/Lib/test/test_configparser.py index 8d82182..37dee74 100644 --- a/Lib/test/test_configparser.py +++ b/Lib/test/test_configparser.py @@ -770,6 +770,33 @@ boolean {0[0]} NO with self.assertRaises(configparser.NoSectionError): cf.items("no such section") + def test_popitem(self): + cf = self.fromstring(""" + [section1] + name1 {0[0]} value1 + [section2] + name2 {0[0]} value2 + [section3] + name3 {0[0]} value3 + """.format(self.delimiters), defaults={"default": "<default>"}) + self.assertEqual(cf.popitem()[0], 'section1') + self.assertEqual(cf.popitem()[0], 'section2') + self.assertEqual(cf.popitem()[0], 'section3') + with self.assertRaises(KeyError): + cf.popitem() + + def test_clear(self): + cf = self.newconfig({"foo": "Bar"}) + self.assertEqual( + cf.get(self.default_section, "Foo"), "Bar", + "could not locate option, expecting case-insensitive option names") + cf['zing'] = {'option1': 'value1', 'option2': 'value2'} + self.assertEqual(cf.sections(), ['zing']) + self.assertEqual(set(cf['zing'].keys()), {'option1', 'option2', 'foo'}) + cf.clear() + self.assertEqual(set(cf.sections()), set()) + self.assertEqual(set(cf[self.default_section].keys()), {'foo'}) + class StrictTestCase(BasicTestCase): config_class = configparser.RawConfigParser |