paul@549 | 1 | #!/usr/bin/env python |
paul@549 | 2 | |
paul@549 | 3 | """ |
paul@549 | 4 | This test attempts to record the usage of 'C', 'D' or 'E' in the module code |
paul@549 | 5 | since 'f' and 'g' might be used, but only 'f' is actually required. Although |
paul@549 | 6 | only 'D' provides both attributes, classes 'C' and 'E' provide 'f'. |
paul@549 | 7 | |
paul@549 | 8 | The local usage of 'g' in the 'local_usage' function is not currently |
paul@549 | 9 | considered. |
paul@549 | 10 | """ |
paul@549 | 11 | |
paul@549 | 12 | class C: |
paul@549 | 13 | def f(self): # unused but retained |
paul@549 | 14 | return 1 |
paul@549 | 15 | |
paul@549 | 16 | class D: |
paul@549 | 17 | def f(self): |
paul@549 | 18 | return 2 |
paul@549 | 19 | |
paul@549 | 20 | def g(self): |
paul@549 | 21 | return 3 |
paul@549 | 22 | |
paul@549 | 23 | class E: |
paul@549 | 24 | def f(self): # unused but retained |
paul@549 | 25 | return 4 |
paul@549 | 26 | |
paul@549 | 27 | def h(self): # unused |
paul@549 | 28 | return 5 |
paul@549 | 29 | |
paul@549 | 30 | def local_usage(): |
paul@549 | 31 | return obj.g() # would indicate D usage |
paul@549 | 32 | |
paul@549 | 33 | c = C() |
paul@549 | 34 | d = D() |
paul@549 | 35 | e = E() |
paul@549 | 36 | |
paul@549 | 37 | obj = c |
paul@549 | 38 | obj = d |
paul@549 | 39 | # obj: f, g; f |
paul@549 | 40 | if obj.f(): |
paul@549 | 41 | x = obj.g() |
paul@549 | 42 | else: |
paul@549 | 43 | x = 2 |
paul@549 | 44 | |
paul@549 | 45 | result1_3 = x |
paul@549 | 46 | result2_3 = local_usage() |
paul@549 | 47 | |
paul@549 | 48 | # vim: tabstop=4 expandtab shiftwidth=4 |