1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/attribute_access_type_restriction_global.py Tue Jun 19 00:29:57 2012 +0200
1.3 @@ -0,0 +1,41 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"""
1.7 +This test attempts to record the usage of 'C', 'D' or 'E' in the module code
1.8 +since 'f' and 'g' might be used, but only 'f' is actually required. Although
1.9 +only 'D' provides both attributes, classes 'C' and 'E' provide 'f'.
1.10 +"""
1.11 +
1.12 +class C:
1.13 + def f(self): # unused but retained
1.14 + return 1
1.15 +
1.16 +class D:
1.17 + def f(self):
1.18 + return 2
1.19 +
1.20 + def g(self):
1.21 + return 3
1.22 +
1.23 +class E:
1.24 + def f(self): # unused but retained
1.25 + return 4
1.26 +
1.27 + def h(self): # unused
1.28 + return 5
1.29 +
1.30 +c = C()
1.31 +d = D()
1.32 +e = E()
1.33 +
1.34 +obj = c
1.35 +obj = d
1.36 + # obj: f, g; f
1.37 +if obj.f():
1.38 + x = obj.g()
1.39 +else:
1.40 + x = 2
1.41 +
1.42 +result_3 = x
1.43 +
1.44 +# vim: tabstop=4 expandtab shiftwidth=4