Jeremy Hylton | 62e2c7e | 2001-02-28 17:48:06 +0000 | [diff] [blame] | 1 | # Test various flavors of legal and illegal future statements |
| 2 | |
| 3 | from test_support import unload |
| 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') |
| 15 | import test_future1 |
| 16 | |
| 17 | unload('test_future2') |
| 18 | import test_future2 |
| 19 | |
| 20 | # The remaining tests should fail |
| 21 | try: |
| 22 | import test_future3 |
| 23 | except SyntaxError, msg: |
| 24 | check_error_location(str(msg)) |
| 25 | |
| 26 | try: |
| 27 | import test_future4 |
| 28 | except SyntaxError, msg: |
| 29 | check_error_location(str(msg)) |
| 30 | |
| 31 | try: |
| 32 | import test_future5 |
| 33 | except SyntaxError, msg: |
| 34 | check_error_location(str(msg)) |
| 35 | |
| 36 | try: |
| 37 | import test_future6 |
| 38 | except SyntaxError, msg: |
| 39 | check_error_location(str(msg)) |
| 40 | |
| 41 | try: |
| 42 | import test_future7 |
| 43 | except SyntaxError, msg: |
| 44 | check_error_location(str(msg)) |