def test_list_with_non_existing_matching_element(self): lst = [1, 3, 5, 7] self.assertIsNone(utils.first_index(lst, lambda e: e == 2))
def test_list_with_existing_matching_element(self): lst = [1, 3, 5, 7] self.assertEqual(0, utils.first_index(lst, lambda e: e == 1)) self.assertEqual(2, utils.first_index(lst, lambda e: e == 5)) self.assertEqual(3, utils.first_index(lst, lambda e: e == 7))
def test_list_with_existing_matching_element(self): lst = [1, 3, 5, 7] self.assertEqual(utils.first_index(lst, lambda e: e == 1), 0) self.assertEqual(utils.first_index(lst, lambda e: e == 5), 2) self.assertEqual(utils.first_index(lst, lambda e: e == 7), 3)