def test_errors(self): def fake(x): raise Exception self.assertRaises(Exception,ex11.sum_functions(fake,abs),5) self.assertRaises(Exception,ex11.sub_functions(fake,abs),5) self.assertRaises(Exception,ex11.mul_functions(fake,abs),5) self.assertRaises(Exception,ex11.div_functions(fake,abs),5) self.assertRaises(Exception,ex11.compose(fake,abs),5) self.assertRaises(Exception,ex11.compose(abs,fake),5) self.assertRaises(Exception,ex11.inverse(fake),5) self.assertRaises(Exception,ex11.derivative(fake),5) self.assertRaises(Exception,ex11.integral_function(fake),5)
def test_sum(self): f = ex11.sum_functions(abs, math.sqrt) self.assertEqual(f(9), 12) self.assertEqual(f(1 / 4), 3 / 4)
def test_sum(self): f = ex11.sum_functions(abs,math.sqrt) self.assertEqual(f(9),12) self.assertEqual(f(1/4),3/4)