def testReduceReferenceCount(self): func = lambda x, y: None x = object() y = object() l = [x, y] rc_func = sys.getrefcount(func) rc_x = sys.getrefcount(x) rc_y = sys.getrefcount(y) pycfunc.reduce(func, l) self.assertEqual(rc_func, sys.getrefcount(func)) self.assertEqual(rc_x, sys.getrefcount(x)) self.assertEqual(rc_y, sys.getrefcount(y))
def testReduce(self): self.assertEqual(45, pycfunc.reduce(lambda x, y: x + y, xrange(10)))