2012-06-04 | Paul Boddie | file changeset files shortlog | Simplify attribute assignment by insisting on the types identified from usage observations, only noting assignments on those and not on any type that could support a particular attribute. |
paul@288 | 1 | #!/usr/bin/env python |
paul@288 | 2 | |
paul@323 | 3 | """ |
paul@323 | 4 | This test attempts to record the usage of 'D' in 'test_conditional' since 'f' |
paul@323 | 5 | and 'g' are both normally required, and only 'D' provides these attributes. |
paul@323 | 6 | Classes 'C' and 'E' should lose their methods, even 'E.f'. |
paul@323 | 7 | """ |
paul@323 | 8 | |
paul@288 | 9 | class C: |
paul@323 | 10 | def f(self): # unused |
paul@288 | 11 | return 1 |
paul@288 | 12 | |
paul@288 | 13 | class D: |
paul@288 | 14 | def f(self): |
paul@288 | 15 | return 2 |
paul@288 | 16 | |
paul@288 | 17 | def g(self): |
paul@288 | 18 | return 3 |
paul@288 | 19 | |
paul@288 | 20 | class E: |
paul@323 | 21 | def f(self): # unused |
paul@288 | 22 | return 4 |
paul@288 | 23 | |
paul@323 | 24 | def h(self): # unused |
paul@288 | 25 | return 5 |
paul@288 | 26 | |
paul@288 | 27 | def test_conditional(obj): |
paul@380 | 28 | # obj: f, g; f |
paul@323 | 29 | if obj.f(): |
paul@323 | 30 | obj.g() |
paul@288 | 31 | return 2 |
paul@288 | 32 | |
paul@288 | 33 | c = C() |
paul@288 | 34 | d = D() |
paul@288 | 35 | e = E() |
paul@288 | 36 | result1_2 = test_conditional(d) |
paul@288 | 37 | |
paul@288 | 38 | # vim: tabstop=4 expandtab shiftwidth=4 |