diff options
author | Łukasz Langa <lukasz@langa.pl> | 2012-12-31 02:38:39 (GMT) |
---|---|---|
committer | Łukasz Langa <lukasz@langa.pl> | 2012-12-31 02:38:39 (GMT) |
commit | 3a8479a5838e0ad4c549d67acfdae2b9e9700e54 (patch) | |
tree | 9acf3eb02f12ce39a73539d41b3f3227e1f6f3d7 /Lib/test | |
parent | 30574695067f948c2ee40d44c06d71e16c6b90f9 (diff) | |
download | cpython-3a8479a5838e0ad4c549d67acfdae2b9e9700e54.zip cpython-3a8479a5838e0ad4c549d67acfdae2b9e9700e54.tar.gz cpython-3a8479a5838e0ad4c549d67acfdae2b9e9700e54.tar.bz2 |
Fixes `parser.clean()` reported in issue #16820.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_cfgparser.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py index a6e9050..7a9e8a8 100644 --- a/Lib/test/test_cfgparser.py +++ b/Lib/test/test_cfgparser.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 |