1 #!/usr/bin/env python 2 3 class C: 4 def f(self): 5 return 1 6 7 class D: 8 def f(self): 9 return 2 10 11 def g(self): 12 return 3 13 14 def test_one(obj): 15 obj.f() 16 return obj.g() 17 18 def test_neither(obj, obj2): 19 if obj.f(): 20 obj = obj2 21 obj.g() 22 return 2 23 24 def test_either(obj, obj2): 25 if obj: 26 obj = obj2 27 obj.g() 28 return obj.f() 29 30 def test_neither2(obj, obj2): 31 if obj: 32 obj.g() 33 else: 34 obj.f() 35 return 4 36 37 c = C() 38 d = D() 39 result1_3 = test_one(d) 40 result1_2 = test_neither(c, d) 41 result2_2 = test_either(c, d) 42 result1_4 = test_neither2(c, d) 43 44 # vim: tabstop=4 expandtab shiftwidth=4