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_mul(self): f = ex11.mul_functions(abs, math.sqrt) self.assertEqual(f(9), 27) self.assertEqual(f(1 / 4), 1 / 8)
def test_mul(self): f = ex11.mul_functions(abs,math.sqrt) self.assertEqual(f(9),27) self.assertEqual(f(1/4),1/8)