Skip to content

Commit

Permalink
check that "private" variables cannot be used as target
Browse files Browse the repository at this point in the history
  • Loading branch information
d-maurer committed Apr 27, 2020
1 parent 9319c0e commit 7ac0481
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/RestrictedPython/tests/test_NamedExpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def test_works(self):
exec(code, gs)
self.assertEqual(gs["x"], 1)

def test_no_private_target(self):
with self.assertRaises(SyntaxError):
compile_str("if _x_:= 1: True\n")

def test_simple_only(self):
# we test here that only a simple variable is allowed
# as assignemt expression target
Expand Down

0 comments on commit 7ac0481

Please sign in to comment.