def test_floats_in_float_out(self): out = avg([1.1, 2.2]) self.assertAlmostEqual(out, 1.65) self.assertEqual(type(out), float)
def test_single_int_in_float_out(self): out = avg([1]) self.assertEqual(out, 1.0) self.assertEqual(type(out), float)
def test_ints_in_float_out(self): out = avg([1, 2]) self.assertEqual(out, 1.5) self.assertEqual(type(out), float)
def test_empty_input_raises_error(self): with self.assertRaises(ZeroDivisionError): avg([])