2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/tests/assign_sequence.py Tue Aug 30 18:59:33 2016 +0200
2.3 @@ -0,0 +1,23 @@
2.4 +def f():
2.5 + l = [1, 2, 3]
2.6 + x = l
2.7 + a, b, c = l
2.8 + d, e, f = [1, 2, 3]
2.9 +
2.10 +def g(x):
2.11 + l = [1, 2, 3]
2.12 + m = [4, l, 6]
2.13 + if x:
2.14 + n = l
2.15 + else:
2.16 + n = m
2.17 +
2.18 +l = [1, 2, 3]
2.19 +x = l
2.20 +a, b, c = l
2.21 +d, e, f = [1, 2, 3]
2.22 +m = [4, l, 6]
2.23 +if x:
2.24 + n = l
2.25 +else:
2.26 + n = m
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/tests/attr_providers.py Tue Aug 30 18:59:33 2016 +0200
3.3 @@ -0,0 +1,25 @@
3.4 +class C:
3.5 + def __init__(self):
3.6 + self.a = 1
3.7 +
3.8 + b = 2
3.9 +
3.10 +class D:
3.11 + def __init__(self):
3.12 + self.a = 3
3.13 + self.b = 4
3.14 +
3.15 +class E:
3.16 + a = 5
3.17 + b = 6
3.18 +
3.19 +def f(x):
3.20 + return x.a, x.b
3.21 +
3.22 +c = C()
3.23 +d = D()
3.24 +e = E()
3.25 +
3.26 +result1 = f(c) # (1, 2)
3.27 +result2 = f(d) # (3, 4)
3.28 +result3 = f(e) # (5, 6)
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/tests/chains/main.py Tue Aug 30 18:59:33 2016 +0200
4.3 @@ -0,0 +1,10 @@
4.4 +import package.module
4.5 +
4.6 +C = package.module.Class
4.7 +c = package
4.8 +d = c
4.9 +e = c.module
4.10 +f = c.module.Class
4.11 +
4.12 +def t():
4.13 + x = c.module.Class
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/tests/chains/package/module.py Tue Aug 30 18:59:33 2016 +0200
5.3 @@ -0,0 +1,2 @@
5.4 +class Class:
5.5 + pass
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/tests/chains/package/unused.py Tue Aug 30 18:59:33 2016 +0200
6.3 @@ -0,0 +1,2 @@
6.4 +class Unused:
6.5 + pass
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/tests/consts.py Tue Aug 30 18:59:33 2016 +0200
7.3 @@ -0,0 +1,12 @@
7.4 +def f():
7.5 + s = "test"
7.6 + m = s.__len__
7.7 + n = "test".__len__
7.8 +
7.9 +def g():
7.10 + l = [1]
7.11 + m = l.__len__
7.12 + n = [1].__len__
7.13 +
7.14 +f()
7.15 +g()
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/tests/dicts.py Tue Aug 30 18:59:33 2016 +0200
9.3 @@ -0,0 +1,10 @@
9.4 +def f(d):
9.5 + return d.keys()
9.6 +
9.7 +def g(d):
9.8 + for key, value in d.items():
9.9 + return value
9.10 +
9.11 +d = {"a" : 1, "b" : 2}
9.12 +f(d) # ["a", "b"]
9.13 +g(d) # either 1 or 2
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/tests/inheritance_bad/A.py Tue Aug 30 18:59:33 2016 +0200
11.3 @@ -0,0 +1,4 @@
11.4 +from B import E
11.5 +
11.6 +class D(E):
11.7 + d = 3
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/tests/inheritance_bad/B.py Tue Aug 30 18:59:33 2016 +0200
12.3 @@ -0,0 +1,4 @@
12.4 +from A import D
12.5 +
12.6 +class E(D):
12.7 + e = 2
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/tests/inheritance_bad/main.py Tue Aug 30 18:59:33 2016 +0200
13.3 @@ -0,0 +1,1 @@
13.4 +import A
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/tests/listcomp.py Tue Aug 30 18:59:33 2016 +0200
14.3 @@ -0,0 +1,4 @@
14.4 +def f(l, y):
14.5 + return [x for x in l if x > y]
14.6 +
14.7 +result = f([1, 2, 3], 2)
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2 +++ b/tests/mutual_import/A.py Tue Aug 30 18:59:33 2016 +0200
15.3 @@ -0,0 +1,10 @@
15.4 +from B import C, g
15.5 +
15.6 +class D(C):
15.7 + d = 3
15.8 +
15.9 +def f(x):
15.10 + return x
15.11 +
15.12 +def h(x):
15.13 + return g(x)
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/tests/mutual_import/B.py Tue Aug 30 18:59:33 2016 +0200
16.3 @@ -0,0 +1,10 @@
16.4 +from A import D, f
16.5 +
16.6 +class C:
16.7 + c = 1
16.8 +
16.9 +class E(D):
16.10 + e = 2
16.11 +
16.12 +def g(x):
16.13 + return f(x)
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
17.2 +++ b/tests/mutual_import/main.py Tue Aug 30 18:59:33 2016 +0200
17.3 @@ -0,0 +1,3 @@
17.4 +import A
17.5 +
17.6 +A.h(A.C())
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
18.2 +++ b/tests/nested.py Tue Aug 30 18:59:33 2016 +0200
18.3 @@ -0,0 +1,11 @@
18.4 +a = 4
18.5 +
18.6 +def f(x):
18.7 + def g(y):
18.8 + def h(z):
18.9 + return x, y, z, a
18.10 + return h
18.11 + return g
18.12 +
18.13 +result = f(1)(2)(3)
18.14 +assert result == (1, 2, 3, 4)
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
19.2 +++ b/tests/nested_bad.py Tue Aug 30 18:59:33 2016 +0200
19.3 @@ -0,0 +1,11 @@
19.4 +def f(x):
19.5 + def g(y):
19.6 + while 1:
19.7 + def h(z):
19.8 + return x, y, z, a
19.9 + a = 4 # not available for h, available in Python
19.10 + return h
19.11 + return g
19.12 +
19.13 +result = f(1)(2)(3)
19.14 +assert result == (1, 2, 3, 4)
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
20.2 +++ b/tests/nested_bad_conditional.py Tue Aug 30 18:59:33 2016 +0200
20.3 @@ -0,0 +1,10 @@
20.4 +a = 4
20.5 +
20.6 +def f(x):
20.7 + if not x:
20.8 + def g(y):
20.9 + return x, y, a
20.10 + return g # UnboundLocalError: not defined if x is true
20.11 +
20.12 +result = f(1)(2)
20.13 +assert result == (1, 2, 4)
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
21.2 +++ b/tests/nested_bad_python.py Tue Aug 30 18:59:33 2016 +0200
21.3 @@ -0,0 +1,13 @@
21.4 +a = 4
21.5 +
21.6 +def f(x):
21.7 + def g():
21.8 + def h(z):
21.9 + return x, y, z, a
21.10 + h(3) # NameError in Python
21.11 + y = 2 # not available for h, detected during inspection
21.12 + return h
21.13 + return g
21.14 +
21.15 +result = f(1)()(3)
21.16 +assert result == (1, 2, 3, 4)
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
22.2 +++ b/tests/nested_lambda.py Tue Aug 30 18:59:33 2016 +0200
22.3 @@ -0,0 +1,8 @@
22.4 +a = 4
22.5 +
22.6 +def f(x):
22.7 + g = lambda y: lambda z: (x, y, z, a)
22.8 + return g
22.9 +
22.10 +result = f(1)(2)(3)
22.11 +assert result == (1, 2, 3, 4)
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
23.2 +++ b/tests/nested_mixed.py Tue Aug 30 18:59:33 2016 +0200
23.3 @@ -0,0 +1,11 @@
23.4 +a = 4
23.5 +
23.6 +def f(x):
23.7 + def g(y):
23.8 + def h(y, z):
23.9 + return x, y, z, a # parameter y overrides outer scope
23.10 + return h
23.11 + return g
23.12 +
23.13 +result = f(1)(2)(5, 3)
23.14 +assert result == (1, 5, 3, 4)
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
24.2 +++ b/tests/nested_mixed_names.py Tue Aug 30 18:59:33 2016 +0200
24.3 @@ -0,0 +1,20 @@
24.4 +class C:
24.5 + def c(self):
24.6 + return 1
24.7 +
24.8 +class D:
24.9 + def d(self):
24.10 + return 3
24.11 +
24.12 +a = 4
24.13 +
24.14 +def f(x):
24.15 + x.c()
24.16 + def g(y): # x introduced as default here
24.17 + if y:
24.18 + x = D()
24.19 + return x.d(), y, a # UnboundLocalError in Python (if y is a false value)
24.20 + return g
24.21 +
24.22 +result = f(C())(2)
24.23 +assert result == (3, 2, 4)
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
25.2 +++ b/tests/nested_value_changed.py Tue Aug 30 18:59:33 2016 +0200
25.3 @@ -0,0 +1,13 @@
25.4 +a = 4
25.5 +
25.6 +def f(x):
25.7 + def g():
25.8 + y = 2 # used to initialise h
25.9 + def h(z):
25.10 + return x, y, z, a
25.11 + y = 5 # Python uses this value directly from g in h
25.12 + return h
25.13 + return g
25.14 +
25.15 +result = f(1)()(3)
25.16 +assert result == (1, 2, 3, 4) # (1, 5, 3, 4) in Python
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
26.2 +++ b/tests/operators.py Tue Aug 30 18:59:33 2016 +0200
26.3 @@ -0,0 +1,7 @@
26.4 +import operator
26.5 +
26.6 +def f(a, op, b):
26.7 + return op(a, b)
26.8 +
26.9 +f(1, operator.add, 2)
26.10 +f(1, operator.sub, 2)