MCPcopy Index your code
hub / github.com/python/cpython / test_add_section

Method test_add_section

Lib/test/test_configparser.py:2213–2227  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2211 self.assertEqual(output.getvalue(), '[section]\n\n')
2212
2213 def test_add_section(self):
2214 cfg = configparser.ConfigParser(allow_unnamed_section=True)
2215 cfg.add_section(configparser.UNNAMED_SECTION)
2216 cfg.set(configparser.UNNAMED_SECTION, 'a', '1')
2217 self.assertEqual('1', cfg[configparser.UNNAMED_SECTION]['a'])
2218 output = io.StringIO()
2219 cfg.write(output)
2220 self.assertEqual(output.getvalue(), 'a = 1\n\n')
2221
2222 cfg = configparser.ConfigParser(allow_unnamed_section=True)
2223 cfg[configparser.UNNAMED_SECTION] = {'a': '1'}
2224 self.assertEqual('1', cfg[configparser.UNNAMED_SECTION]['a'])
2225 output = io.StringIO()
2226 cfg.write(output)
2227 self.assertEqual(output.getvalue(), 'a = 1\n\n')
2228
2229 def test_disabled_error(self):
2230 with self.assertRaises(configparser.MissingSectionHeaderError):

Callers

nothing calls this directly

Calls 5

add_sectionMethod · 0.95
setMethod · 0.95
getvalueMethod · 0.95
assertEqualMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected