Jeremy Hylton | 62e2c7e | 2001-02-28 17:48:06 +0000 | [diff] [blame] | 1 | # Test various flavors of legal and illegal future statements |
| 2 | |
Barry Warsaw | 04f357c | 2002-07-23 19:04:11 +0000 | [diff] [blame] | 3 | from test.test_support import unload |
Jeremy Hylton | 62e2c7e | 2001-02-28 17:48:06 +0000 | [diff] [blame] | 4 | import re |
| 5 | |
| 6 | rx = re.compile('\((\S+).py, line (\d+)') |
| 7 | |
| 8 | def check_error_location(msg): |
| 9 | mo = rx.search(msg) |
| 10 | print "SyntaxError %s %s" % mo.group(1, 2) |
| 11 | |
| 12 | # The first two tests should work |
| 13 | |
| 14 | unload('test_future1') |
Barry Warsaw | 408b6d3 | 2002-07-30 23:27:12 +0000 | [diff] [blame^] | 15 | from test import test_future1 |
Jeremy Hylton | 62e2c7e | 2001-02-28 17:48:06 +0000 | [diff] [blame] | 16 | |
| 17 | unload('test_future2') |
Barry Warsaw | 408b6d3 | 2002-07-30 23:27:12 +0000 | [diff] [blame^] | 18 | from test import test_future2 |
Jeremy Hylton | 62e2c7e | 2001-02-28 17:48:06 +0000 | [diff] [blame] | 19 | |
Jeremy Hylton | 8471a35 | 2001-08-20 20:33:42 +0000 | [diff] [blame] | 20 | unload('test_future3') |
Barry Warsaw | 408b6d3 | 2002-07-30 23:27:12 +0000 | [diff] [blame^] | 21 | from test import test_future3 |
Jeremy Hylton | 8471a35 | 2001-08-20 20:33:42 +0000 | [diff] [blame] | 22 | |
Jeremy Hylton | 62e2c7e | 2001-02-28 17:48:06 +0000 | [diff] [blame] | 23 | # The remaining tests should fail |
| 24 | try: |
Barry Warsaw | 408b6d3 | 2002-07-30 23:27:12 +0000 | [diff] [blame^] | 25 | from test import badsyntax_future3 |
Jeremy Hylton | 62e2c7e | 2001-02-28 17:48:06 +0000 | [diff] [blame] | 26 | except SyntaxError, msg: |
| 27 | check_error_location(str(msg)) |
| 28 | |
| 29 | try: |
Barry Warsaw | 408b6d3 | 2002-07-30 23:27:12 +0000 | [diff] [blame^] | 30 | from test import badsyntax_future4 |
Jeremy Hylton | 62e2c7e | 2001-02-28 17:48:06 +0000 | [diff] [blame] | 31 | except SyntaxError, msg: |
| 32 | check_error_location(str(msg)) |
| 33 | |
| 34 | try: |
Barry Warsaw | 408b6d3 | 2002-07-30 23:27:12 +0000 | [diff] [blame^] | 35 | from test import badsyntax_future5 |
Jeremy Hylton | 62e2c7e | 2001-02-28 17:48:06 +0000 | [diff] [blame] | 36 | except SyntaxError, msg: |
| 37 | check_error_location(str(msg)) |
| 38 | |
| 39 | try: |
Barry Warsaw | 408b6d3 | 2002-07-30 23:27:12 +0000 | [diff] [blame^] | 40 | from test import badsyntax_future6 |
Jeremy Hylton | 62e2c7e | 2001-02-28 17:48:06 +0000 | [diff] [blame] | 41 | except SyntaxError, msg: |
| 42 | check_error_location(str(msg)) |
| 43 | |
| 44 | try: |
Barry Warsaw | 408b6d3 | 2002-07-30 23:27:12 +0000 | [diff] [blame^] | 45 | from test import badsyntax_future7 |
Jeremy Hylton | 62e2c7e | 2001-02-28 17:48:06 +0000 | [diff] [blame] | 46 | except SyntaxError, msg: |
| 47 | check_error_location(str(msg)) |