def fake_request(*responses):
    """
    Creates a request function that returns the supplied responses, one at a time.
    Making a new request after the last response has been returned results in a StopIteration error.
    """
    iterator = (response for response in responses)

    def request(method, url, **kwargs):
        return next(iterator)

    return request