#4529: fix parser's validation for try-except-finally statements.

This commit is contained in:
Georg Brandl 2008-12-05 12:09:41 +00:00
parent 3129ea2e05
commit fe879e8a23
3 changed files with 36 additions and 23 deletions

View file

@ -200,6 +200,16 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
self.check_suite("with open('x'): pass\n")
self.check_suite("with open('x') as f: pass\n")
def test_try_stmt(self):
self.check_suite("try: pass\nexcept: pass\n")
self.check_suite("try: pass\nfinally: pass\n")
self.check_suite("try: pass\nexcept A: pass\nfinally: pass\n")
self.check_suite("try: pass\nexcept A: pass\nexcept: pass\n"
"finally: pass\n")
self.check_suite("try: pass\nexcept: pass\nelse: pass\n")
self.check_suite("try: pass\nexcept: pass\nelse: pass\n"
"finally: pass\n")
def test_position(self):
# An absolutely minimal test of position information. Better
# tests would be a big project.