MCPcopy Index your code
hub / github.com/RustPython/RustPython / raisesSyntaxError

Function raisesSyntaxError

extra_tests/snippets/syntax_forbidden_name.py:3–8  ·  view source on GitHub ↗
(parse_stmt, exec_stmt=None)

Source from the content-addressed store, hash-verified

1from testutils import assert_raises
2
3def raisesSyntaxError(parse_stmt, exec_stmt=None):
4 with assert_raises(SyntaxError):
5 compile(parse_stmt, '<test>', 'exec')
6 if exec_stmt is not None:
7 source = "\n".join([parse_stmt, exec_stmt])
8 exec(source)
9
10# Check that errors are raised during parsing.
11raisesSyntaxError("def f(**__debug__): pass")

Callers 1

Calls 4

assert_raisesFunction · 0.90
execFunction · 0.70
compileFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected