def test_first(self):
    iterations = [0]

    def predicate(value):
        iterations[0] += 1
        if (value == 5):
            return True
        return False
    self.assertEqual(5, first(predicate, range(10)))
    self.assertEqual(iterations[0], 6)
    iterations[0] = 0
    self.assertIsNone(first(predicate, range(10, 20)))
    self.assertEqual(iterations[0], 10)
def test_first(self):
    iterations = [0]

    def predicate(value):
        iterations[0] += 1
        if (value == 5):
            return True
        return False
    self.assertEqual(5, first(predicate, range(10)))
    self.assertEqual(iterations[0], 6)
    iterations[0] = 0
    self.assertIsNone(first(predicate, range(10, 20)))
    self.assertEqual(iterations[0], 10)