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

Function check_syntax_error

Lib/test/support/__init__.py:827–836  ·  view source on GitHub ↗
(testcase, statement, errtext='', *, lineno=None, offset=None)

Source from the content-addressed store, hash-verified

825
826
827def check_syntax_error(testcase, statement, errtext='', *, lineno=None, offset=None):
828 with testcase.assertRaisesRegex(SyntaxError, errtext) as cm:
829 compile(statement, '<test string>', 'exec')
830 err = cm.exception
831 testcase.assertIsNotNone(err.lineno)
832 if lineno is not None:
833 testcase.assertEqual(err.lineno, lineno)
834 testcase.assertIsNotNone(err.offset)
835 if offset is not None:
836 testcase.assertEqual(err.offset, offset)
837
838
839def open_urlresource(url, *args, **kw):

Callers 15

test_funcdefMethod · 0.90
test_lambdefMethod · 0.90
test_expr_stmtMethod · 0.90
test_returnMethod · 0.90
test_yieldMethod · 0.90
test_listcompsMethod · 0.90
test_genexpsMethod · 0.90
test_name_paramMethod · 0.90

Calls 4

assertRaisesRegexMethod · 0.80
assertIsNotNoneMethod · 0.80
compileFunction · 0.50
assertEqualMethod · 0.45

Tested by 15

test_funcdefMethod · 0.72
test_lambdefMethod · 0.72
test_expr_stmtMethod · 0.72
test_returnMethod · 0.72
test_yieldMethod · 0.72
test_listcompsMethod · 0.72
test_genexpsMethod · 0.72
test_name_paramMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…