mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
gh-127096: Do not recreate unnamed section on every read in ConfigParser (#127228)
* Do not recreate unnamed section on every read in ConfigParser * Remove duplicate section creation code
This commit is contained in:
parent
5d9b62005a
commit
914c232e93
3 changed files with 15 additions and 8 deletions
|
@ -2174,6 +2174,15 @@ class SectionlessTestCase(unittest.TestCase):
|
|||
with self.assertRaises(configparser.UnnamedSectionDisabledError):
|
||||
configparser.ConfigParser().add_section(configparser.UNNAMED_SECTION)
|
||||
|
||||
def test_multiple_configs(self):
|
||||
cfg = configparser.ConfigParser(allow_unnamed_section=True)
|
||||
cfg.read_string('a = 1')
|
||||
cfg.read_string('b = 2')
|
||||
|
||||
self.assertEqual([configparser.UNNAMED_SECTION], cfg.sections())
|
||||
self.assertEqual('1', cfg[configparser.UNNAMED_SECTION]['a'])
|
||||
self.assertEqual('2', cfg[configparser.UNNAMED_SECTION]['b'])
|
||||
|
||||
|
||||
class MiscTestCase(unittest.TestCase):
|
||||
def test__all__(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue