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

Method test_parse_errors

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

Source from the content-addressed store, hash-verified

527 "could not locate option, expecting case-insensitive defaults")
528
529 def test_parse_errors(self):
530 cf = self.newconfig()
531 self.parse_error(cf, configparser.ParsingError,
532 "[Foo]\n"
533 "{}val-without-opt-name\n".format(self.delimiters[0]))
534 self.parse_error(cf, configparser.ParsingError,
535 "[Foo]\n"
536 "{}val-without-opt-name\n".format(self.delimiters[1]))
537 e = self.parse_error(cf, configparser.MissingSectionHeaderError,
538 "No Section!\n")
539 self.assertEqual(e.args, ('<???>', 1, "No Section!\n"))
540 if not self.allow_no_value:
541 e = self.parse_error(cf, configparser.ParsingError,
542 "[Foo]\n wrong-indent\n")
543 self.assertEqual(e.args, ('<???>',))
544 # read_file on a real file
545 tricky = support.findfile("cfgparser.3", subdir="configdata")
546 if self.delimiters[0] == '=':
547 error = configparser.ParsingError
548 expected = (tricky,)
549 else:
550 error = configparser.MissingSectionHeaderError
551 expected = (tricky, 1,
552 ' # INI with as many tricky parts as possible\n')
553 with open(tricky, encoding='utf-8') as f:
554 e = self.parse_error(cf, error, f)
555 self.assertEqual(e.args, expected)
556
557 def parse_error(self, cf, exc, src):
558 if hasattr(src, 'readline'):

Callers

nothing calls this directly

Calls 5

parse_errorMethod · 0.95
openFunction · 0.50
newconfigMethod · 0.45
formatMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected