import requests


def fail_response(request):
    """Create a Response with a failing status code or exception."""
    def req(url):
        if request.param == 'error':
            raise requests.exceptions.ConnectionError

        class Response(object):
            status_code = request.param

        return Response

    return req