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