def test_average1(self): answer = avg.compute_average([1, 2, 3, 4, 5]) self.assertEqual(answer, 3.0)
def test_average2(self): answer = avg.compute_average([2, 3, 4, 5, 6]) self.assertEqual(answer, 4.0)
def test_empty_input_average(self): answer = avg.compute_average([]) self.assertEqual(answer, 0)
def test_average3(self): answer = avg.compute_average(['w', 3, 4, 5, 6]) self.assertRaisesRegex(ValueError, 'number')
def test_float_input_number(self): self.assertEqual(avg.compute_average([2.7, 2.8, 4.8, 4.9]), 3)
def test_average(self): answer = avg.compute_average([1, 2, 3, 4, 5]) self.assertEqual(answer, 3.0) answer = avg.compute_average([2, 4]) self.assertTrue(answer == 3)
def test_wrong_average(self): answer = avg.compute_average([2, 4]) self.assertFalse(answer == 2)