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

Method test_weird_errors

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

Source from the content-addressed store, hash-verified

615 cf.getboolean, 'BOOLTEST', 'e%d' % x)
616
617 def test_weird_errors(self):
618 cf = self.newconfig()
619 cf.add_section("Foo")
620 with self.assertRaises(configparser.DuplicateSectionError) as cm:
621 cf.add_section("Foo")
622 e = cm.exception
623 self.assertEqual(str(e), "Section 'Foo' already exists")
624 self.assertEqual(e.args, ("Foo", None, None))
625
626 if self.strict:
627 with self.assertRaises(configparser.DuplicateSectionError) as cm:
628 cf.read_string(textwrap.dedent("""\
629 [Foo]
630 will this be added{equals}True
631 [Bar]
632 what about this{equals}True
633 [Foo]
634 oops{equals}this won't
635 """.format(equals=self.delimiters[0])), source='<foo-bar>')
636 e = cm.exception
637 self.assertEqual(str(e), "While reading from '<foo-bar>' "
638 "[line 5]: section 'Foo' already exists")
639 self.assertEqual(e.args, ("Foo", '<foo-bar>', 5))
640
641 with self.assertRaises(configparser.DuplicateOptionError) as cm:
642 cf.read_dict({'Bar': {'opt': 'val', 'OPT': 'is really `opt`'}})
643 e = cm.exception
644 self.assertEqual(str(e), "While reading from '<dict>': option "
645 "'opt' in section 'Bar' already exists")
646 self.assertEqual(e.args, ("Bar", "opt", "<dict>", None))
647
648 def test_get_after_duplicate_option_error(self):
649 cf = self.newconfig()

Callers

nothing calls this directly

Calls 9

strFunction · 0.85
read_stringMethod · 0.80
read_dictMethod · 0.80
newconfigMethod · 0.45
add_sectionMethod · 0.45
assertRaisesMethod · 0.45
assertEqualMethod · 0.45
dedentMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected