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

Method check_script_error

Lib/test/test_source_encoding.py:503–513  ·  view source on GitHub ↗
(self, src, expected, lineno=...)

Source from the content-addressed store, hash-verified

501 self.assertEqual(out.rstrip(), expected)
502
503 def check_script_error(self, src, expected, lineno=...):
504 with self.assertRaises(SyntaxError) as cm:
505 exec(src)
506 exc = cm.exception
507 self.assertRegex(str(exc), expected.decode())
508 if lineno is not ...:
509 self.assertEqual(exc.lineno, lineno)
510 line = src.splitlines()[lineno-1].decode(errors='replace')
511 if lineno == 1:
512 line = line.removeprefix('\ufeff')
513 self.assertEqual(line, exc.text)
514
515
516@support.force_not_colorized_test_class

Callers

nothing calls this directly

Calls 7

strFunction · 0.85
assertRegexMethod · 0.80
assertRaisesMethod · 0.45
decodeMethod · 0.45
assertEqualMethod · 0.45
splitlinesMethod · 0.45
removeprefixMethod · 0.45

Tested by

no test coverage detected