File: test_future.py

package info (click to toggle)
python2.1 2.1.3-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 33,848 kB
  • ctags: 64,354
  • sloc: python: 186,805; ansic: 184,797; xml: 43,435; sh: 3,875; makefile: 3,118; perl: 3,108; lisp: 2,460; cpp: 106; sed: 2
file content (44 lines) | stat: -rw-r--r-- 858 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Test various flavors of legal and illegal future statements

from test_support import unload
import re

rx = re.compile('\((\S+).py, line (\d+)')

def check_error_location(msg):
    mo = rx.search(msg)
    print "SyntaxError %s %s" % mo.group(1, 2)

# The first two tests should work

unload('test_future1')
import test_future1

unload('test_future2')
import test_future2

# The remaining tests should fail
try:
    import test_future3
except SyntaxError, msg:
    check_error_location(str(msg))

try:
    import test_future4
except SyntaxError, msg:
    check_error_location(str(msg))

try:
    import test_future5
except SyntaxError, msg:
    check_error_location(str(msg))

try:
    import test_future6
except SyntaxError, msg:
    check_error_location(str(msg))

try:
    import test_future7
except SyntaxError, msg:
    check_error_location(str(msg))