def open(self, *args, **kwargs):
        as_tuple = kwargs.pop('as_tuple', False)
        buffered = kwargs.pop('buffered', False)
        follow_redirects = kwargs.pop('follow_redirects', False)
        environ = None
        if not kwargs and len(args) == 1:
            if isinstance(args[0], EnvironBuilder):
                environ = args[0].get_environ()
            elif isinstance(args[0], dict):
                environ = args[0]
        if environ is None:
            builder = EnvironBuilder(*args, **kwargs)
            try:
                environ = builder.get_environ()
            finally:
                builder.close()

        if self.cookie_jar is not None:
            self.cookie_jar.inject_wsgi(environ)
        rv = run_wsgi_app(self.application, environ, buffered=buffered)
        if self.cookie_jar is not None:
            self.cookie_jar.extract_wsgi(environ, rv[2])

        # handle redirects
        redirect_chain = []
        status_code = int(rv[1].split(None, 1)[0])
        while status_code in (301, 302, 303, 305, 307) and follow_redirects:
            if not self.redirect_client:
                # assume that we're not using the user defined response wrapper
                # so that we don't need any ugly hacks to get the status
                # code from the response.
                self.redirect_client = Client(self.application)
                self.redirect_client.cookie_jar = self.cookie_jar

            redirect = dict(rv[2])['Location']
            scheme, netloc, script_root, qs, anchor = urlparse.urlsplit(redirect)
            base_url = urlparse.urlunsplit((scheme, netloc, '', '', '')).rstrip('/') + '/'
            host = get_host(create_environ('/', base_url, query_string=qs)).split(':', 1)[0]
            if get_host(environ).split(':', 1)[0] != host:
                raise RuntimeError('%r does not support redirect to '
                                   'external targets' % self.__class__)

            redirect_chain.append((redirect, status_code))

            # the redirect request should be a new request, and not be based on
            # the old request
            redirect_kwargs = {}
            redirect_kwargs.update({
                'path':             script_root,
                'base_url':         base_url,
                'query_string':     qs,
                'as_tuple':         True,
                'buffered':         buffered,
                'follow_redirects': False,
            })
            environ, rv = self.redirect_client.open(**redirect_kwargs)
            status_code = int(rv[1].split(None, 1)[0])

            # Prevent loops
            if redirect_chain[-1] in redirect_chain[0:-1]:
                raise ClientRedirectError("loop detected")

        response = self.response_wrapper(*rv)
        if as_tuple:
            return environ, response
        return response
Takes the same arguments as the :class:`EnvironBuilder` class with
dataset/ETHPy150Open IanLewis/kay/kay/lib/werkzeug/test.py/Client.open