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

Method test_compile_invalid_namedexpr

Lib/test/test_compile.py:500–525  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

498 """), '<eval>', 'exec')
499
500 def test_compile_invalid_namedexpr(self):
501 # gh-109351
502 m = ast.Module(
503 body=[
504 ast.Expr(
505 value=ast.ListComp(
506 elt=ast.NamedExpr(
507 target=ast.Constant(value=1),
508 value=ast.Constant(value=3),
509 ),
510 generators=[
511 ast.comprehension(
512 target=ast.Name(id="x", ctx=ast.Store()),
513 iter=ast.Name(id="y", ctx=ast.Load()),
514 ifs=[],
515 is_async=0,
516 )
517 ],
518 )
519 )
520 ],
521 type_ignores=[],
522 )
523
524 with self.assertRaisesRegex(TypeError, "NamedExpr target must be a Name"):
525 compile(ast.fix_missing_locations(m), "<file>", "exec")
526
527 def test_compile_redundant_jumps_and_nops_after_moving_cold_blocks(self):
528 # See gh-120367

Callers

nothing calls this directly

Calls 3

LoadMethod · 0.80
assertRaisesRegexMethod · 0.80
compileFunction · 0.50

Tested by

no test coverage detected