This commit is contained in:
Raymond Hettinger 2013-03-22 07:26:57 -07:00
commit 671ddbe5a0
1 changed files with 4 additions and 2 deletions

View File

@ -281,8 +281,10 @@ file::
def test_average(self): def test_average(self):
self.assertEqual(average([20, 30, 70]), 40.0) self.assertEqual(average([20, 30, 70]), 40.0)
self.assertEqual(round(average([1, 5, 7]), 1), 4.3) self.assertEqual(round(average([1, 5, 7]), 1), 4.3)
self.assertRaises(ZeroDivisionError, average, []) with self.assertRaises(ZeroDivisionError):
self.assertRaises(TypeError, average, 20, 30, 70) average([])
with self.assertRaises(TypeError):
average(20, 30, 70)
unittest.main() # Calling from the command line invokes all tests unittest.main() # Calling from the command line invokes all tests