##// END OF EJS Templates
test-check-code.t: test matching try/except/finally introduced in aeeb2afcdc25
Thomas Arendsen Hein -
r15285:42e71f58 stable
parent child Browse files
Show More
@@ -1,114 +1,134 b''
1 $ cat > correct.py <<EOF
1 $ cat > correct.py <<EOF
2 > def toto(arg1, arg2):
2 > def toto(arg1, arg2):
3 > del arg2
3 > del arg2
4 > return (5 + 6, 9)
4 > return (5 + 6, 9)
5 > EOF
5 > EOF
6 $ cat > wrong.py <<EOF
6 $ cat > wrong.py <<EOF
7 > def toto( arg1, arg2):
7 > def toto( arg1, arg2):
8 > del(arg2)
8 > del(arg2)
9 > return ( 5+6, 9)
9 > return ( 5+6, 9)
10 > EOF
10 > EOF
11 $ cat > quote.py <<EOF
11 $ cat > quote.py <<EOF
12 > # let's use quote in comments
12 > # let's use quote in comments
13 > (''' ( 4x5 )
13 > (''' ( 4x5 )
14 > but """\\''' and finally''',
14 > but """\\''' and finally''',
15 > """let's fool checkpatch""", '1+2',
15 > """let's fool checkpatch""", '1+2',
16 > '"""', 42+1, """and
16 > '"""', 42+1, """and
17 > ( 4-1 ) """, "( 1+1 )\" and ")
17 > ( 4-1 ) """, "( 1+1 )\" and ")
18 > a, '\\\\\\\\', "\\\\\\" x-2", "c-1"
18 > a, '\\\\\\\\', "\\\\\\" x-2", "c-1"
19 > EOF
19 > EOF
20 $ cat > non-py24.py <<EOF
20 $ cat > non-py24.py <<EOF
21 > # Using builtins that does not exist in Python 2.4
21 > # Using builtins that does not exist in Python 2.4
22 > if any():
22 > if any():
23 > x = all()
23 > x = all()
24 > y = format(x)
24 > y = format(x)
25 >
25 >
26 > # Do not complain about our own definition
26 > # Do not complain about our own definition
27 > def any(x):
27 > def any(x):
28 > pass
28 > pass
29 >
30 > # try/except/finally block does not exist in Python 2.4
31 > try:
32 > pass
33 > except StandardError, inst:
34 > pass
35 > finally:
36 > pass
37 >
38 > # nested try/finally+try/except is allowed
39 > try:
40 > try:
41 > pass
42 > except StandardError, inst:
43 > pass
44 > finally:
45 > pass
29 > EOF
46 > EOF
30 $ cat > classstyle.py <<EOF
47 $ cat > classstyle.py <<EOF
31 > class newstyle_class(object):
48 > class newstyle_class(object):
32 > pass
49 > pass
33 >
50 >
34 > class oldstyle_class:
51 > class oldstyle_class:
35 > pass
52 > pass
36 >
53 >
37 > class empty():
54 > class empty():
38 > pass
55 > pass
39 >
56 >
40 > no_class = 1:
57 > no_class = 1:
41 > pass
58 > pass
42 > EOF
59 > EOF
43 $ check_code="$TESTDIR"/../contrib/check-code.py
60 $ check_code="$TESTDIR"/../contrib/check-code.py
44 $ "$check_code" ./wrong.py ./correct.py ./quote.py ./non-py24.py ./classstyle.py
61 $ "$check_code" ./wrong.py ./correct.py ./quote.py ./non-py24.py ./classstyle.py
45 ./wrong.py:1:
62 ./wrong.py:1:
46 > def toto( arg1, arg2):
63 > def toto( arg1, arg2):
47 gratuitous whitespace in () or []
64 gratuitous whitespace in () or []
48 ./wrong.py:2:
65 ./wrong.py:2:
49 > del(arg2)
66 > del(arg2)
50 Python keyword is not a function
67 Python keyword is not a function
51 ./wrong.py:3:
68 ./wrong.py:3:
52 > return ( 5+6, 9)
69 > return ( 5+6, 9)
53 gratuitous whitespace in () or []
70 gratuitous whitespace in () or []
54 missing whitespace in expression
71 missing whitespace in expression
55 ./quote.py:5:
72 ./quote.py:5:
56 > '"""', 42+1, """and
73 > '"""', 42+1, """and
57 missing whitespace in expression
74 missing whitespace in expression
58 ./non-py24.py:2:
75 ./non-py24.py:2:
59 > if any():
76 > if any():
60 any/all/format not available in Python 2.4
77 any/all/format not available in Python 2.4
61 ./non-py24.py:3:
78 ./non-py24.py:3:
62 > x = all()
79 > x = all()
63 any/all/format not available in Python 2.4
80 any/all/format not available in Python 2.4
64 ./non-py24.py:4:
81 ./non-py24.py:4:
65 > y = format(x)
82 > y = format(x)
66 any/all/format not available in Python 2.4
83 any/all/format not available in Python 2.4
84 ./non-py24.py:11:
85 > try:
86 no try/except/finally in Py2.4
67 ./classstyle.py:4:
87 ./classstyle.py:4:
68 > class oldstyle_class:
88 > class oldstyle_class:
69 old-style class, use class foo(object)
89 old-style class, use class foo(object)
70 ./classstyle.py:7:
90 ./classstyle.py:7:
71 > class empty():
91 > class empty():
72 class foo() not available in Python 2.4, use class foo(object)
92 class foo() not available in Python 2.4, use class foo(object)
73 [1]
93 [1]
74
94
75 $ cat > is-op.py <<EOF
95 $ cat > is-op.py <<EOF
76 > # is-operator comparing number or string literal
96 > # is-operator comparing number or string literal
77 > x = None
97 > x = None
78 > y = x is 'foo'
98 > y = x is 'foo'
79 > y = x is "foo"
99 > y = x is "foo"
80 > y = x is 5346
100 > y = x is 5346
81 > y = x is -6
101 > y = x is -6
82 > y = x is not 'foo'
102 > y = x is not 'foo'
83 > y = x is not "foo"
103 > y = x is not "foo"
84 > y = x is not 5346
104 > y = x is not 5346
85 > y = x is not -6
105 > y = x is not -6
86 > EOF
106 > EOF
87
107
88 $ "$check_code" ./is-op.py
108 $ "$check_code" ./is-op.py
89 ./is-op.py:3:
109 ./is-op.py:3:
90 > y = x is 'foo'
110 > y = x is 'foo'
91 object comparison with literal
111 object comparison with literal
92 ./is-op.py:4:
112 ./is-op.py:4:
93 > y = x is "foo"
113 > y = x is "foo"
94 object comparison with literal
114 object comparison with literal
95 ./is-op.py:5:
115 ./is-op.py:5:
96 > y = x is 5346
116 > y = x is 5346
97 object comparison with literal
117 object comparison with literal
98 ./is-op.py:6:
118 ./is-op.py:6:
99 > y = x is -6
119 > y = x is -6
100 object comparison with literal
120 object comparison with literal
101 ./is-op.py:7:
121 ./is-op.py:7:
102 > y = x is not 'foo'
122 > y = x is not 'foo'
103 object comparison with literal
123 object comparison with literal
104 ./is-op.py:8:
124 ./is-op.py:8:
105 > y = x is not "foo"
125 > y = x is not "foo"
106 object comparison with literal
126 object comparison with literal
107 ./is-op.py:9:
127 ./is-op.py:9:
108 > y = x is not 5346
128 > y = x is not 5346
109 object comparison with literal
129 object comparison with literal
110 ./is-op.py:10:
130 ./is-op.py:10:
111 > y = x is not -6
131 > y = x is not -6
112 object comparison with literal
132 object comparison with literal
113 [1]
133 [1]
114
134
General Comments 0
You need to be logged in to leave comments. Login now