1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/attribute_access_type_restriction_global_usage.py Tue Jun 19 00:29:57 2012 +0200
1.3 @@ -0,0 +1,48 @@
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 +The local usage of 'g' in the 'local_usage' function is not currently
1.12 +considered.
1.13 +"""
1.14 +
1.15 +class C:
1.16 + def f(self): # unused but retained
1.17 + return 1
1.18 +
1.19 +class D:
1.20 + def f(self):
1.21 + return 2
1.22 +
1.23 + def g(self):
1.24 + return 3
1.25 +
1.26 +class E:
1.27 + def f(self): # unused but retained
1.28 + return 4
1.29 +
1.30 + def h(self): # unused
1.31 + return 5
1.32 +
1.33 +def local_usage():
1.34 + return obj.g() # would indicate D usage
1.35 +
1.36 +c = C()
1.37 +d = D()
1.38 +e = E()
1.39 +
1.40 +obj = c
1.41 +obj = d
1.42 + # obj: f, g; f
1.43 +if obj.f():
1.44 + x = obj.g()
1.45 +else:
1.46 + x = 2
1.47 +
1.48 +result1_3 = x
1.49 +result2_3 = local_usage()
1.50 +
1.51 +# vim: tabstop=4 expandtab shiftwidth=4