def test_maxlist_rec(self): tlist = [10, 9, 8 ,4, 9] self.assertEqual(sample.maxlist_rec(tlist),10) tlist = [9, 8, 10 ,4, 9] self.assertEqual(sample.maxlist_rec(tlist),10) tlist = [5, 9, 8 ,4, 10] self.assertEqual(sample.maxlist_rec(tlist),10) tlist = [-10, -9, -1 ,-4, -9] self.assertEqual(sample.maxlist_rec(tlist),-1) tlist = [] with self.assertRaises(ValueError): # uses context manager to check exception sample.maxlist_rec(tlist)
def test_maxlist_rec(self): tlist = [10, 9, 8, 4, 9] self.assertEqual(sample.maxlist_rec(tlist),10) tlist = [9, 8, 10, 4, 9] self.assertEqual(sample.maxlist_rec(tlist),10) tlist = [5, 9, 8, 4, 10] self.assertEqual(sample.maxlist_rec(tlist),10) tlist = [-10, -9, -1, -4, -9] self.assertEqual(sample.maxlist_rec(tlist),-1) tlist = [] with self.assertRaises(ValueError): # uses context manager to check exception sample.maxlist_rec(tlist) self.assertRaises(ValueError, sample.maxlist_rec, tlist) # another way to check exception # when items in list are all the same tlist = [2, 2, 2, 2, 2] self.assertEqual(sample.maxlist_rec(tlist), 2) # when there is negative and positive values in the list tlist = [-2, -4, 1, -1, 0] self.assertEqual(sample.maxlist_rec(tlist), 1)
def test_maxlist_rec(self): tlist = [10, 9, 8, 4, 9] self.assertEqual(sample.maxlist_rec(tlist), 10) tlist = [9, 8, 10, 4, 9] self.assertEqual(sample.maxlist_rec(tlist), 10) tlist = [5, 9, 8, 4, 10] self.assertEqual(sample.maxlist_rec(tlist), 10) tlist = [-10, -9, -1, -4, -9] self.assertEqual(sample.maxlist_rec(tlist), -1) tlist = [] with self.assertRaises(ValueError): # check for correct Exception sample.maxlist_rec(tlist) self.assertRaises(ValueError, sample.maxlist_rec, tlist) # another way to check exception