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

Method test_no_first_section

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

Source from the content-addressed store, hash-verified

2163 return cfg
2164
2165 def test_no_first_section(self):
2166 cfg1 = self.fromstring("""
2167 a = 1
2168 b = 2
2169 [sect1]
2170 c = 3
2171 """)
2172
2173 self.assertEqual(set([configparser.UNNAMED_SECTION, 'sect1']), set(cfg1.sections()))
2174 self.assertEqual('1', cfg1[configparser.UNNAMED_SECTION]['a'])
2175 self.assertEqual('2', cfg1[configparser.UNNAMED_SECTION]['b'])
2176 self.assertEqual('3', cfg1['sect1']['c'])
2177
2178 output = io.StringIO()
2179 cfg1.write(output)
2180 cfg2 = self.fromstring(output.getvalue())
2181
2182 #self.assertEqual(set([configparser.UNNAMED_SECTION, 'sect1']), set(cfg2.sections()))
2183 self.assertEqual('1', cfg2[configparser.UNNAMED_SECTION]['a'])
2184 self.assertEqual('2', cfg2[configparser.UNNAMED_SECTION]['b'])
2185 self.assertEqual('3', cfg2['sect1']['c'])
2186
2187 def test_no_section(self):
2188 cfg1 = self.fromstring("""

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected