mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
[3.13] gh-127096: Do not recreate unnamed section on every read in ConfigParser (GH-127228) (#129593)
* Do not recreate unnamed section on every read in ConfigParser
* Remove duplicate section creation code
(cherry picked from commit 914c232e93
)
Co-authored-by: Andrey Efremov <duxus@yandex.ru>
This commit is contained in:
parent
65f3432ac3
commit
6aa09a5898
3 changed files with 15 additions and 8 deletions
|
@ -2161,6 +2161,15 @@ class SectionlessTestCase(unittest.TestCase):
|
|||
self.assertEqual('1', cfg2[configparser.UNNAMED_SECTION]['a'])
|
||||
self.assertEqual('2', cfg2[configparser.UNNAMED_SECTION]['b'])
|
||||
|
||||
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