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

Method test_no_section

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

Source from the content-addressed store, hash-verified

2185 self.assertEqual('3', cfg2['sect1']['c'])
2186
2187 def test_no_section(self):
2188 cfg1 = self.fromstring("""
2189 a = 1
2190 b = 2
2191 """)
2192
2193 self.assertEqual([configparser.UNNAMED_SECTION], cfg1.sections())
2194 self.assertEqual('1', cfg1[configparser.UNNAMED_SECTION]['a'])
2195 self.assertEqual('2', cfg1[configparser.UNNAMED_SECTION]['b'])
2196
2197 output = io.StringIO()
2198 cfg1.write(output)
2199 cfg2 = self.fromstring(output.getvalue())
2200
2201 self.assertEqual([configparser.UNNAMED_SECTION], cfg2.sections())
2202 self.assertEqual('1', cfg2[configparser.UNNAMED_SECTION]['a'])
2203 self.assertEqual('2', cfg2[configparser.UNNAMED_SECTION]['b'])
2204
2205 def test_empty_unnamed_section(self):
2206 cfg = configparser.ConfigParser(allow_unnamed_section=True)

Callers

nothing calls this directly

Calls 5

fromstringMethod · 0.95
getvalueMethod · 0.95
assertEqualMethod · 0.45
sectionsMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected