2013-10-08 | Paul Boddie | file changeset files shortlog | Fixed relative import path interpretation to work within package roots. | syspython-as-target |
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 | |
paul@549 | 9 | class C: |
paul@549 | 10 | def f(self): # unused but retained |
paul@549 | 11 | return 1 |
paul@549 | 12 | |
paul@549 | 13 | class D: |
paul@549 | 14 | def f(self): |
paul@549 | 15 | return 2 |
paul@549 | 16 | |
paul@549 | 17 | def g(self): |
paul@549 | 18 | return 3 |
paul@549 | 19 | |
paul@549 | 20 | class E: |
paul@549 | 21 | def f(self): # unused but retained |
paul@549 | 22 | return 4 |
paul@549 | 23 | |
paul@549 | 24 | def h(self): # unused |
paul@549 | 25 | return 5 |
paul@549 | 26 | |
paul@549 | 27 | c = C() |
paul@549 | 28 | d = D() |
paul@549 | 29 | e = E() |
paul@549 | 30 | |
paul@549 | 31 | obj = c |
paul@549 | 32 | obj = d |
paul@549 | 33 | # obj: f, g; f |
paul@549 | 34 | if obj.f(): |
paul@549 | 35 | x = obj.g() |
paul@549 | 36 | else: |
paul@549 | 37 | x = 2 |
paul@549 | 38 | |
paul@549 | 39 | result_3 = x |
paul@549 | 40 | |
paul@549 | 41 | # vim: tabstop=4 expandtab shiftwidth=4 |