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

Method test_basic

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

Source from the content-addressed store, hash-verified

292 # and sections are now removed.
293
294 def test_basic(self):
295 config_string = """\
296[Foo Bar]
297foo{0[0]}bar1
298[Spacey Bar]
299foo {0[0]} bar2
300[Spacey Bar From The Beginning]
301 foo {0[0]} bar3
302 baz {0[0]} qwe
303[Commented Bar]
304foo{0[1]} bar4 {1[1]} comment
305baz{0[0]}qwe {1[0]}another one
306[Long Line]
307foo{0[1]} this line is much, much longer than my editor
308 likes it.
309[Section\\with$weird%characters[\t]
310[Internationalized Stuff]
311foo[bg]{0[1]} Bulgarian
312foo{0[0]}Default
313foo[en]{0[0]}English
314foo[de]{0[0]}Deutsch
315[Spaces]
316key with spaces {0[1]} value
317another with spaces {0[0]} splat!
318[Types]
319int {0[1]} 42
320float {0[0]} 0.44
321boolean {0[0]} NO
322123 {0[1]} strange but acceptable
323[This One Has A ] In It]
324 forks {0[0]} spoons
325""".format(self.delimiters, self.comment_prefixes)
326 if self.allow_no_value:
327 config_string += (
328 "[NoValue]\n"
329 "option-without-value\n"
330 )
331 cf = self.fromstring(config_string)
332 self.basic_test(cf)
333 if self.strict:
334 with self.assertRaises(configparser.DuplicateOptionError):
335 cf.read_string(textwrap.dedent("""\
336 [Duplicate Options Here]
337 option {0[0]} with a value
338 option {0[1]} with another value
339 """.format(self.delimiters)))
340 with self.assertRaises(configparser.DuplicateSectionError):
341 cf.read_string(textwrap.dedent("""\
342 [And Now For Something]
343 completely different {0[0]} True
344 [And Now For Something]
345 the larch {0[1]} 1
346 """.format(self.delimiters)))
347 else:
348 cf.read_string(textwrap.dedent("""\
349 [Duplicate Options Here]
350 option {0[0]} with a value
351 option {0[1]} with another value

Callers

nothing calls this directly

Calls 6

basic_testMethod · 0.95
read_stringMethod · 0.80
formatMethod · 0.45
fromstringMethod · 0.45
assertRaisesMethod · 0.45
dedentMethod · 0.45

Tested by

no test coverage detected