def test_noneAttribute(self): """ Test that None attributes named the same as the method we are collecting are not silently ignored. """ class A(object): foo = None class B(A): pass results1 = list(collectMethods(A(), 'foo')) self.assertEquals(len(results1), 1) results2 = list(collectMethods(B(), 'foo')) self.assertEquals(len(results2), 1) self.assertRaises(TypeError, results2[0])
def test_simpleUsage(self): class A(object): def foo(self): return 'A' class B(A): def foo(self): return 'B' results = [m() for m in collectMethods(B(), 'foo')] self.assertEquals(results, ['B', 'A'])
def test_missingMethod(self): class A(object): def foo(self): return 'A' class B(A): pass class C(B): def foo(self): return 'C' results = [m() for m in collectMethods(C(), 'foo')] self.assertEquals(results, ['C', 'A'])