Issue #14696: Fix parser module to understand 'nonlocal' declarations.

This commit is contained in:
Mark Dickinson 2012-04-29 22:18:31 +01:00
parent 2420d83158
commit 407b3bd89b
3 changed files with 48 additions and 5 deletions

View file

@ -57,6 +57,16 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
" if (yield):\n"
" yield x\n")
def test_nonlocal_statement(self):
self.check_suite("def f():\n"
" x = 0\n"
" def g():\n"
" nonlocal x\n")
self.check_suite("def f():\n"
" x = y = 0\n"
" def g():\n"
" nonlocal x, y\n")
def test_expressions(self):
self.check_expr("foo(1)")
self.check_expr("[1, 2, 3]")