{
    "file_diffs": [
        {
            "old_file_content": "__all__ = ['BaseConnector', 'TCPConnector', 'UnixConnector',\n           'SocketConnector', 'UnixSocketConnector', 'ProxyConnector']\n\nimport asyncio\nimport aiohttp\nimport functools\nimport http.cookies\nimport time\nimport ssl\nimport socket\nimport weakref\n\nfrom .errors import HttpProxyError\nfrom .errors import ProxyConnectionError\nfrom .client import ClientRequest\n\n\nclass Connection(object):\n\n    def __init__(self, connector, key, request, transport, protocol):\n        self._key = key\n        self._connector = connector\n        self._request = request\n        self._transport = transport\n        self._protocol = protocol\n        self.reader = protocol.reader\n        self.writer = protocol.writer\n        self._wr = weakref.ref(self, lambda wr, tr=self._transport: tr.close())\n\n    def close(self):\n        if self._transport is not None:\n            self._transport.close()\n            self._transport = None\n            self._wr = None\n\n    def release(self):\n        if self._transport:\n            self._connector._release(\n                self._key, self._request, self._transport, self._protocol)\n            self._transport = None\n            self._wr = None\n\n\nclass BaseConnector(object):\n\n    def __init__(self, *, conn_timeout=None, keepalive_timeout=30,\n                 share_cookies=False, force_close=False, loop=None, **kwargs):\n        self._conns = {}\n        self._conn_timeout = conn_timeout\n        self._keepalive_timeout = keepalive_timeout\n        self._share_cookies = share_cookies\n        self._cleanup_handle = None\n        self._force_close = force_close\n\n        if loop is None:\n            loop = asyncio.get_event_loop()\n        self._loop = loop\n        self._factory = functools.partial(aiohttp.StreamProtocol, loop=loop)\n\n        self.cookies = http.cookies.SimpleCookie()\n        self._wr = weakref.ref(\n            self, lambda wr, f=self._do_close, conns=self._conns: f(conns))\n\n    def _cleanup(self):\n        \"\"\"Cleanup unused transports.\"\"\"\n        if self._cleanup_handle:\n            self._cleanup_handle.cancel()\n            self._cleanup_handle = None\n\n        now = time.time()\n\n        connections = {}\n        for key, conns in self._conns.items():\n            alive = []\n            for transport, proto, t0 in conns:\n                if transport is not None:\n                    if proto and not proto.is_connected():\n                        transport = None\n                    elif (now - t0) > self._keepalive_timeout:\n                        transport.close()\n                        transport = None\n\n                if transport:\n                    alive.append((transport, proto, t0))\n            if alive:\n                connections[key] = alive\n\n        if connections:\n            self._cleanup_handle = self._loop.call_later(\n                self._keepalive_timeout, self._cleanup)\n\n        self._conns = connections\n        self._wr = weakref.ref(\n            self, lambda wr, f=self._do_close, conns=self._conns: f(conns))\n\n    def _start_cleanup_task(self):\n        if self._cleanup_handle is None:\n            self._cleanup_handle = self._loop.call_later(\n                self._keepalive_timeout, self._cleanup)\n\n    def close(self):\n        \"\"\"Close all opened transports.\"\"\"\n        self._do_close(self._conns)\n\n    @staticmethod\n    def _do_close(conns):\n        for key, data in conns.items():\n            for transport, proto, td in data:\n                transport.close()\n\n        conns.clear()\n\n    def update_cookies(self, cookies):\n        if isinstance(cookies, dict):\n            cookies = cookies.items()\n\n        for name, value in cookies:\n            if isinstance(value, http.cookies.Morsel):\n                # use dict method because SimpleCookie class modifies value\n                dict.__setitem__(self.cookies, name, value)\n            else:\n                self.cookies[name] = value\n\n    @asyncio.coroutine\n    def connect(self, req):\n        key = (req.host, req.port, req.ssl)\n\n        if self._share_cookies:\n            req.update_cookies(self.cookies.items())\n\n        transport, proto = self._get(key)\n        if transport is None:\n            if self._conn_timeout:\n                transport, proto = yield from asyncio.wait_for(\n                    self._create_connection(req),\n                    self._conn_timeout, loop=self._loop)\n            else:\n                transport, proto = yield from self._create_connection(req)\n\n        return Connection(self, key, req, transport, proto)\n\n    def _get(self, key):\n        conns = self._conns.get(key)\n        while conns:\n            transport, proto, t0 = conns.pop()\n            if transport is not None and proto.is_connected():\n                if (time.time() - t0) > self._keepalive_timeout:\n                    transport.close()\n                    transport = None\n                else:\n                    return transport, proto\n\n        return None, None\n\n    def _release(self, key, req, transport, protocol):\n        resp = req.response\n        should_close = False\n\n        if resp is not None:\n            if resp.message is None:\n                should_close = True\n            else:\n                should_close = resp.message.should_close\n                if self._share_cookies and resp.cookies:\n                    self.update_cookies(resp.cookies.items())\n\n        if self._force_close:\n            should_close = True\n\n        reader = protocol.reader\n        if should_close or (reader.output and not reader.output.at_eof()):\n            transport.close()\n        else:\n            conns = self._conns.get(key)\n            if conns is None:\n                conns = self._conns[key] = []\n            conns.append((transport, protocol, time.time()))\n            reader.unset_parser()\n\n            self._start_cleanup_task()\n\n    def _create_connection(self, req, *args, **kwargs):\n        raise NotImplementedError()\n\n\nclass TCPConnector(BaseConnector):\n\n    def __init__(self, *args, verify_ssl=True,\n                 resolve=False, family=socket.AF_INET, **kwargs):\n        super().__init__(*args, **kwargs)\n\n        self._verify_ssl = verify_ssl\n        self._family = family\n        self._resolve = resolve\n        self._resolved_hosts = {}\n\n    @property\n    def verify_ssl(self):\n        \"\"\"Do check for ssl certifications?\"\"\"\n        return self._verify_ssl\n\n    @property\n    def family(self):\n        \"\"\"Socket family like AF_INET\"\"\"\n        return self._family\n\n    @property\n    def resolve(self):\n        \"\"\"Do DNS lookup for host name?\"\"\"\n        return self._resolve\n\n    @property\n    def resolved_hosts(self):\n        \"\"\"The dict of (host, port) -> (ipaddr, port) pairs\"\"\"\n        return dict(self._resolved_hosts)\n\n    def clear_resolved_hosts(self, host=None, port=None):\n        if host is not None and port is not None:\n            key = (host, port)\n            if key in self._resolved_hosts:\n                del self._resolved_hosts[key]\n        else:\n            self._resolved_hosts.clear()\n\n    @asyncio.coroutine\n    def _resolve_host(self, host, port):\n        if self._resolve:\n            key = (host, port)\n\n            if key not in self._resolved_hosts:\n                infos = yield from self._loop.getaddrinfo(\n                    host, port, type=socket.SOCK_STREAM, family=self._family)\n\n                hosts = []\n                for family, _, proto, _, address in infos:\n                    hosts.append(\n                        {'hostname': host,\n                         'host': address[0], 'port': address[1],\n                         'family': family, 'proto': proto,\n                         'flags': socket.AI_NUMERICHOST})\n                self._resolved_hosts[key] = hosts\n\n            return list(self._resolved_hosts[key])\n        else:\n            return [{'hostname': host, 'host': host, 'port': port,\n                     'family': self._family, 'proto': 0, 'flags': 0}]\n\n    def _create_connection(self, req, **kwargs):\n        \"\"\"Create connection. Has same keyword arguments\n        as BaseEventLoop.create_connection\n        \"\"\"\n        sslcontext = req.ssl\n        if req.ssl and not self._verify_ssl:\n            sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)\n            sslcontext.options |= ssl.OP_NO_SSLv2\n            sslcontext.set_default_verify_paths()\n\n        hosts = yield from self._resolve_host(req.host, req.port)\n\n        while hosts:\n            hinfo = hosts.pop()\n            try:\n                return (yield from self._loop.create_connection(\n                    self._factory, hinfo['host'], hinfo['port'],\n                    ssl=sslcontext, family=hinfo['family'],\n                    proto=hinfo['proto'], flags=hinfo['flags'],\n                    server_hostname=hinfo['hostname'] if sslcontext else None,\n                    **kwargs))\n            except OSError:\n                if not hosts:\n                    raise\n\n\nclass ProxyConnector(TCPConnector):\n    \"\"\"Http Proxy connector.\"\"\"\n\n    def __init__(self, proxy, proxy_login=None, proxy_passwd=None,\n                 *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._proxy = proxy\n        self._basic_login = proxy_login\n        self._basic_passwd = proxy_passwd\n        assert proxy.startswith('http://'), (\n            \"Only http proxy supported\", proxy)\n\n    @property\n    def proxy(self):\n        return self._proxy\n\n    @asyncio.coroutine\n    def _create_connection(self, req, **kwargs):\n        proxy_req = ClientRequest(\n            'GET', self._proxy,\n            headers={'Host': req.host},\n            auth=aiohttp.BasicAuth(self._basic_login, self._basic_passwd),\n            loop=self._loop)\n        try:\n            transport, proto = yield from super()._create_connection(proxy_req)\n        except OSError as exc:\n            raise ProxyConnectionError(*exc.args) from exc\n        req.path = '{scheme}://{host}{path}'.format(scheme=req.scheme,\n                                                    host=req.host,\n                                                    path=req.path)\n        if 'AUTHORIZATION' in proxy_req.headers:\n            auth = proxy_req.headers['AUTHORIZATION']\n            del proxy_req.headers['AUTHORIZATION']\n            req.headers['PROXY-AUTHORIZATION'] = auth\n\n        if req.ssl:\n            # For HTTPS requests over HTTP proxy\n            # we must notify proxy to tunnel connection\n            # so we send CONNECT command:\n            #   CONNECT www.python.org:443 HTTP/1.1\n            #   Host: www.python.org\n            #\n            # next we must do TLS handshake and so on\n            # to do this we must wrap raw socket into secure one\n            # asyncio handles this perfectly\n            proxy_req.method = 'CONNECT'\n            proxy_req.path = '{}:{}'.format(req.host, req.port)\n            key = (req.host, req.port, req.ssl)\n            conn = Connection(self, key, proxy_req, transport, proto)\n            proxy_resp = proxy_req.send(conn.writer, conn.reader)\n            try:\n                resp = yield from proxy_resp.start(conn, True)\n            except:\n                proxy_resp.close()\n                conn.close()\n                raise\n            else:\n                if resp.status != 200:\n                    raise HttpProxyError(resp.status, resp.reason)\n                rawsock = transport.get_extra_info('socket', default=None)\n                if rawsock is None:\n                    raise RuntimeError(\n                        \"Transport does not expose socket instance\")\n                transport.pause_reading()\n                transport, proto = yield from self._loop.create_connection(\n                    self._factory, ssl=True, sock=rawsock,\n                    server_hostname=req.host, **kwargs)\n\n        return transport, proto\n\n\nclass UnixConnector(BaseConnector):\n\n    def __init__(self, path, *args, **kw):\n        super().__init__(*args, **kw)\n\n        self._path = path\n\n    @property\n    def path(self):\n        \"\"\"Path to unix socket\"\"\"\n        return self._path\n\n    @asyncio.coroutine\n    def _create_connection(self, req, **kwargs):\n        return (yield from self._loop.create_unix_connection(\n            self._factory, self._path, **kwargs))\n\n\nSocketConnector = TCPConnector\nUnixSocketConnector = UnixConnector\n",
            "new_file_content": "__all__ = ['BaseConnector', 'TCPConnector', 'UnixConnector',\n           'SocketConnector', 'UnixSocketConnector', 'ProxyConnector']\n\nimport asyncio\nimport aiohttp\nimport functools\nimport http.cookies\nimport time\nimport ssl\nimport socket\nimport weakref\n\nfrom .errors import HttpProxyError\nfrom .errors import ProxyConnectionError\nfrom .client import ClientRequest, BasicAuth\n\n\nclass Connection(object):\n\n    def __init__(self, connector, key, request, transport, protocol):\n        self._key = key\n        self._connector = connector\n        self._request = request\n        self._transport = transport\n        self._protocol = protocol\n        self.reader = protocol.reader\n        self.writer = protocol.writer\n        self._wr = weakref.ref(self, lambda wr, tr=self._transport: tr.close())\n\n    def close(self):\n        if self._transport is not None:\n            self._transport.close()\n            self._transport = None\n            self._wr = None\n\n    def release(self):\n        if self._transport:\n            self._connector._release(\n                self._key, self._request, self._transport, self._protocol)\n            self._transport = None\n            self._wr = None\n\n\nclass BaseConnector(object):\n\n    def __init__(self, *, conn_timeout=None, keepalive_timeout=30,\n                 share_cookies=False, force_close=False, loop=None, **kwargs):\n        self._conns = {}\n        self._conn_timeout = conn_timeout\n        self._keepalive_timeout = keepalive_timeout\n        self._share_cookies = share_cookies\n        self._cleanup_handle = None\n        self._force_close = force_close\n\n        if loop is None:\n            loop = asyncio.get_event_loop()\n        self._loop = loop\n        self._factory = functools.partial(aiohttp.StreamProtocol, loop=loop)\n\n        self.cookies = http.cookies.SimpleCookie()\n        self._wr = weakref.ref(\n            self, lambda wr, f=self._do_close, conns=self._conns: f(conns))\n\n    def _cleanup(self):\n        \"\"\"Cleanup unused transports.\"\"\"\n        if self._cleanup_handle:\n            self._cleanup_handle.cancel()\n            self._cleanup_handle = None\n\n        now = time.time()\n\n        connections = {}\n        for key, conns in self._conns.items():\n            alive = []\n            for transport, proto, t0 in conns:\n                if transport is not None:\n                    if proto and not proto.is_connected():\n                        transport = None\n                    elif (now - t0) > self._keepalive_timeout:\n                        transport.close()\n                        transport = None\n\n                if transport:\n                    alive.append((transport, proto, t0))\n            if alive:\n                connections[key] = alive\n\n        if connections:\n            self._cleanup_handle = self._loop.call_later(\n                self._keepalive_timeout, self._cleanup)\n\n        self._conns = connections\n        self._wr = weakref.ref(\n            self, lambda wr, f=self._do_close, conns=self._conns: f(conns))\n\n    def _start_cleanup_task(self):\n        if self._cleanup_handle is None:\n            self._cleanup_handle = self._loop.call_later(\n                self._keepalive_timeout, self._cleanup)\n\n    def close(self):\n        \"\"\"Close all opened transports.\"\"\"\n        self._do_close(self._conns)\n\n    @staticmethod\n    def _do_close(conns):\n        for key, data in conns.items():\n            for transport, proto, td in data:\n                transport.close()\n\n        conns.clear()\n\n    def update_cookies(self, cookies):\n        if isinstance(cookies, dict):\n            cookies = cookies.items()\n\n        for name, value in cookies:\n            if isinstance(value, http.cookies.Morsel):\n                # use dict method because SimpleCookie class modifies value\n                dict.__setitem__(self.cookies, name, value)\n            else:\n                self.cookies[name] = value\n\n    @asyncio.coroutine\n    def connect(self, req):\n        key = (req.host, req.port, req.ssl)\n\n        if self._share_cookies:\n            req.update_cookies(self.cookies.items())\n\n        transport, proto = self._get(key)\n        if transport is None:\n            if self._conn_timeout:\n                transport, proto = yield from asyncio.wait_for(\n                    self._create_connection(req),\n                    self._conn_timeout, loop=self._loop)\n            else:\n                transport, proto = yield from self._create_connection(req)\n\n        return Connection(self, key, req, transport, proto)\n\n    def _get(self, key):\n        conns = self._conns.get(key)\n        while conns:\n            transport, proto, t0 = conns.pop()\n            if transport is not None and proto.is_connected():\n                if (time.time() - t0) > self._keepalive_timeout:\n                    transport.close()\n                    transport = None\n                else:\n                    return transport, proto\n\n        return None, None\n\n    def _release(self, key, req, transport, protocol):\n        resp = req.response\n        should_close = False\n\n        if resp is not None:\n            if resp.message is None:\n                should_close = True\n            else:\n                should_close = resp.message.should_close\n                if self._share_cookies and resp.cookies:\n                    self.update_cookies(resp.cookies.items())\n\n        if self._force_close:\n            should_close = True\n\n        reader = protocol.reader\n        if should_close or (reader.output and not reader.output.at_eof()):\n            transport.close()\n        else:\n            conns = self._conns.get(key)\n            if conns is None:\n                conns = self._conns[key] = []\n            conns.append((transport, protocol, time.time()))\n            reader.unset_parser()\n\n            self._start_cleanup_task()\n\n    def _create_connection(self, req, *args, **kwargs):\n        raise NotImplementedError()\n\n\nclass TCPConnector(BaseConnector):\n\n    def __init__(self, *args, verify_ssl=True,\n                 resolve=False, family=socket.AF_INET, **kwargs):\n        super().__init__(*args, **kwargs)\n\n        self._verify_ssl = verify_ssl\n        self._family = family\n        self._resolve = resolve\n        self._resolved_hosts = {}\n\n    @property\n    def verify_ssl(self):\n        \"\"\"Do check for ssl certifications?\"\"\"\n        return self._verify_ssl\n\n    @property\n    def family(self):\n        \"\"\"Socket family like AF_INET\"\"\"\n        return self._family\n\n    @property\n    def resolve(self):\n        \"\"\"Do DNS lookup for host name?\"\"\"\n        return self._resolve\n\n    @property\n    def resolved_hosts(self):\n        \"\"\"The dict of (host, port) -> (ipaddr, port) pairs\"\"\"\n        return dict(self._resolved_hosts)\n\n    def clear_resolved_hosts(self, host=None, port=None):\n        if host is not None and port is not None:\n            key = (host, port)\n            if key in self._resolved_hosts:\n                del self._resolved_hosts[key]\n        else:\n            self._resolved_hosts.clear()\n\n    @asyncio.coroutine\n    def _resolve_host(self, host, port):\n        if self._resolve:\n            key = (host, port)\n\n            if key not in self._resolved_hosts:\n                infos = yield from self._loop.getaddrinfo(\n                    host, port, type=socket.SOCK_STREAM, family=self._family)\n\n                hosts = []\n                for family, _, proto, _, address in infos:\n                    hosts.append(\n                        {'hostname': host,\n                         'host': address[0], 'port': address[1],\n                         'family': family, 'proto': proto,\n                         'flags': socket.AI_NUMERICHOST})\n                self._resolved_hosts[key] = hosts\n\n            return list(self._resolved_hosts[key])\n        else:\n            return [{'hostname': host, 'host': host, 'port': port,\n                     'family': self._family, 'proto': 0, 'flags': 0}]\n\n    def _create_connection(self, req, **kwargs):\n        \"\"\"Create connection. Has same keyword arguments\n        as BaseEventLoop.create_connection\n        \"\"\"\n        sslcontext = req.ssl\n        if req.ssl and not self._verify_ssl:\n            sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)\n            sslcontext.options |= ssl.OP_NO_SSLv2\n            sslcontext.set_default_verify_paths()\n\n        hosts = yield from self._resolve_host(req.host, req.port)\n\n        while hosts:\n            hinfo = hosts.pop()\n            try:\n                return (yield from self._loop.create_connection(\n                    self._factory, hinfo['host'], hinfo['port'],\n                    ssl=sslcontext, family=hinfo['family'],\n                    proto=hinfo['proto'], flags=hinfo['flags'],\n                    server_hostname=hinfo['hostname'] if sslcontext else None,\n                    **kwargs))\n            except OSError:\n                if not hosts:\n                    raise\n\n\nclass ProxyConnector(TCPConnector):\n    \"\"\"Http Proxy connector.\"\"\"\n\n    def __init__(self, proxy, *args, proxy_auth=None, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._proxy = proxy\n        self._proxy_auth = proxy_auth\n        assert proxy.startswith('http://'), (\n            \"Only http proxy supported\", proxy)\n        assert proxy_auth is None or isinstance(proxy_auth, BasicAuth), (\n            \"proxy_auth must be None or BasicAuth() tuple\", proxy_auth)\n\n    @property\n    def proxy(self):\n        return self._proxy\n\n    @asyncio.coroutine\n    def _create_connection(self, req, **kwargs):\n        proxy_req = ClientRequest(\n            'GET', self._proxy,\n            headers={'Host': req.host},\n            auth=self._proxy_auth,\n            loop=self._loop)\n        try:\n            transport, proto = yield from super()._create_connection(proxy_req)\n        except OSError as exc:\n            raise ProxyConnectionError(*exc.args) from exc\n        req.path = '{scheme}://{host}{path}'.format(scheme=req.scheme,\n                                                    host=req.host,\n                                                    path=req.path)\n        if 'AUTHORIZATION' in proxy_req.headers:\n            auth = proxy_req.headers['AUTHORIZATION']\n            del proxy_req.headers['AUTHORIZATION']\n            req.headers['PROXY-AUTHORIZATION'] = auth\n\n        if req.ssl:\n            # For HTTPS requests over HTTP proxy\n            # we must notify proxy to tunnel connection\n            # so we send CONNECT command:\n            #   CONNECT www.python.org:443 HTTP/1.1\n            #   Host: www.python.org\n            #\n            # next we must do TLS handshake and so on\n            # to do this we must wrap raw socket into secure one\n            # asyncio handles this perfectly\n            proxy_req.method = 'CONNECT'\n            proxy_req.path = '{}:{}'.format(req.host, req.port)\n            key = (req.host, req.port, req.ssl)\n            conn = Connection(self, key, proxy_req, transport, proto)\n            proxy_resp = proxy_req.send(conn.writer, conn.reader)\n            try:\n                resp = yield from proxy_resp.start(conn, True)\n            except:\n                proxy_resp.close()\n                conn.close()\n                raise\n            else:\n                if resp.status != 200:\n                    raise HttpProxyError(resp.status, resp.reason)\n                rawsock = transport.get_extra_info('socket', default=None)\n                if rawsock is None:\n                    raise RuntimeError(\n                        \"Transport does not expose socket instance\")\n                transport.pause_reading()\n                transport, proto = yield from self._loop.create_connection(\n                    self._factory, ssl=True, sock=rawsock,\n                    server_hostname=req.host, **kwargs)\n\n        return transport, proto\n\n\nclass UnixConnector(BaseConnector):\n\n    def __init__(self, path, *args, **kw):\n        super().__init__(*args, **kw)\n\n        self._path = path\n\n    @property\n    def path(self):\n        \"\"\"Path to unix socket\"\"\"\n        return self._path\n\n    @asyncio.coroutine\n    def _create_connection(self, req, **kwargs):\n        return (yield from self._loop.create_unix_connection(\n            self._factory, self._path, **kwargs))\n\n\nSocketConnector = TCPConnector\nUnixSocketConnector = UnixConnector\n",
            "header": {
                "file": {
                    "path": "aiohttp/connector.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "680062de",
                "new_commit_hash": "56bbc038",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/aiohttp/connector.py"
            },
            "plus_file": {
                "path": "b/aiohttp/connector.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 12,
                            "length": 7
                        },
                        "new_range": {
                            "start": 12,
                            "length": 7
                        },
                        "section": "import weakref"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "from .errors import HttpProxyError",
                                "type": "context"
                            },
                            {
                                "content": "from .errors import ProxyConnectionError",
                                "type": "context"
                            },
                            {
                                "content": "from .client import ClientRequest",
                                "type": "deleted"
                            },
                            {
                                "content": "from .client import ClientRequest, BasicAuth",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "class Connection(object):",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [],
                    "added_entities": [
                        {
                            "file_name": "aiohttp/connector.py",
                            "type": "statement",
                            "name": "",
                            "content": "from .client import ClientRequest, BasicAuth",
                            "ast_type_str": "ImportFrom",
                            "start_lineno": 15,
                            "end_lineno": 15,
                            "parent": null
                        }
                    ],
                    "deleted_entities": [
                        {
                            "file_name": "aiohttp/connector.py",
                            "type": "statement",
                            "name": "",
                            "content": "from .client import ClientRequest",
                            "ast_type_str": "ImportFrom",
                            "start_lineno": 15,
                            "end_lineno": 15,
                            "parent": null
                        }
                    ]
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 274,
                            "length": 14
                        },
                        "new_range": {
                            "start": 274,
                            "length": 14
                        },
                        "section": "class TCPConnector(BaseConnector):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "class ProxyConnector(TCPConnector):",
                                "type": "context"
                            },
                            {
                                "content": "    \"\"\"Http Proxy connector.\"\"\"",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def __init__(self, proxy, proxy_login=None, proxy_passwd=None,",
                                "type": "deleted"
                            },
                            {
                                "content": "                 *args, **kwargs):",
                                "type": "deleted"
                            },
                            {
                                "content": "    def __init__(self, proxy, *args, proxy_auth=None, **kwargs):",
                                "type": "added"
                            },
                            {
                                "content": "        super().__init__(*args, **kwargs)",
                                "type": "context"
                            },
                            {
                                "content": "        self._proxy = proxy",
                                "type": "context"
                            },
                            {
                                "content": "        self._basic_login = proxy_login",
                                "type": "deleted"
                            },
                            {
                                "content": "        self._basic_passwd = proxy_passwd",
                                "type": "deleted"
                            },
                            {
                                "content": "        self._proxy_auth = proxy_auth",
                                "type": "added"
                            },
                            {
                                "content": "        assert proxy.startswith('http://'), (",
                                "type": "context"
                            },
                            {
                                "content": "            \"Only http proxy supported\", proxy)",
                                "type": "context"
                            },
                            {
                                "content": "        assert proxy_auth is None or isinstance(proxy_auth, BasicAuth), (",
                                "type": "added"
                            },
                            {
                                "content": "            \"proxy_auth must be None or BasicAuth() tuple\", proxy_auth)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    @property",
                                "type": "context"
                            },
                            {
                                "content": "    def proxy(self):",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "aiohttp/connector.py",
                            "type": "class",
                            "name": "ProxyConnector",
                            "content": "class ProxyConnector(TCPConnector):\n    \"\"\"Http Proxy connector.\"\"\"\n\n    def __init__(self, proxy, proxy_login=None, proxy_passwd=None,\n                 *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._proxy = proxy\n        self._basic_login = proxy_login\n        self._basic_passwd = proxy_passwd\n        assert proxy.startswith('http://'), (\n            \"Only http proxy supported\", proxy)\n\n    @property\n    def proxy(self):\n        return self._proxy\n\n    @asyncio.coroutine\n    def _create_connection(self, req, **kwargs):\n        proxy_req = ClientRequest(\n            'GET', self._proxy,\n            headers={'Host': req.host},\n            auth=aiohttp.BasicAuth(self._basic_login, self._basic_passwd),\n            loop=self._loop)\n        try:\n            transport, proto = yield from super()._create_connection(proxy_req)\n        except OSError as exc:\n            raise ProxyConnectionError(*exc.args) from exc\n        req.path = '{scheme}://{host}{path}'.format(scheme=req.scheme,\n                                                    host=req.host,\n                                                    path=req.path)\n        if 'AUTHORIZATION' in proxy_req.headers:\n            auth = proxy_req.headers['AUTHORIZATION']\n            del proxy_req.headers['AUTHORIZATION']\n            req.headers['PROXY-AUTHORIZATION'] = auth\n\n        if req.ssl:\n            # For HTTPS requests over HTTP proxy\n            # we must notify proxy to tunnel connection\n            # so we send CONNECT command:\n            #   CONNECT www.python.org:443 HTTP/1.1\n            #   Host: www.python.org\n            #\n            # next we must do TLS handshake and so on\n            # to do this we must wrap raw socket into secure one\n            # asyncio handles this perfectly\n            proxy_req.method = 'CONNECT'\n            proxy_req.path = '{}:{}'.format(req.host, req.port)\n            key = (req.host, req.port, req.ssl)\n            conn = Connection(self, key, proxy_req, transport, proto)\n            proxy_resp = proxy_req.send(conn.writer, conn.reader)\n            try:\n                resp = yield from proxy_resp.start(conn, True)\n            except:\n                proxy_resp.close()\n                conn.close()\n                raise\n            else:\n                if resp.status != 200:\n                    raise HttpProxyError(resp.status, resp.reason)\n                rawsock = transport.get_extra_info('socket', default=None)\n                if rawsock is None:\n                    raise RuntimeError(\n                        \"Transport does not expose socket instance\")\n                transport.pause_reading()\n                transport, proto = yield from self._loop.create_connection(\n                    self._factory, ssl=True, sock=rawsock,\n                    server_hostname=req.host, **kwargs)\n\n        return transport, proto",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 274,
                            "end_lineno": 342,
                            "parent": null
                        },
                        {
                            "file_name": "aiohttp/connector.py",
                            "type": "method",
                            "name": "ProxyConnector.__init__",
                            "content": "class ProxyConnector(TCPConnector):\n    \"\"\"Http Proxy connector.\"\"\"\n\n    def __init__(self, proxy, proxy_login=None, proxy_passwd=None,\n                 *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._proxy = proxy\n        self._basic_login = proxy_login\n        self._basic_passwd = proxy_passwd\n        assert proxy.startswith('http://'), (\n            \"Only http proxy supported\", proxy)\n\n    @property\n    def proxy(self):\n        return self._proxy\n\n    @asyncio.coroutine\n    def _create_connection(self, req, **kwargs):\n        proxy_req = ClientRequest(\n            'GET', self._proxy,\n            headers={'Host': req.host},\n            auth=aiohttp.BasicAuth(self._basic_login, self._basic_passwd),\n            loop=self._loop)\n        try:\n            transport, proto = yield from super()._create_connection(proxy_req)\n        except OSError as exc:\n            raise ProxyConnectionError(*exc.args) from exc\n        req.path = '{scheme}://{host}{path}'.format(scheme=req.scheme,\n                                                    host=req.host,\n                                                    path=req.path)\n        if 'AUTHORIZATION' in proxy_req.headers:\n            auth = proxy_req.headers['AUTHORIZATION']\n            del proxy_req.headers['AUTHORIZATION']\n            req.headers['PROXY-AUTHORIZATION'] = auth\n\n        if req.ssl:\n            # For HTTPS requests over HTTP proxy\n            # we must notify proxy to tunnel connection\n            # so we send CONNECT command:\n            #   CONNECT www.python.org:443 HTTP/1.1\n            #   Host: www.python.org\n            #\n            # next we must do TLS handshake and so on\n            # to do this we must wrap raw socket into secure one\n            # asyncio handles this perfectly\n            proxy_req.method = 'CONNECT'\n            proxy_req.path = '{}:{}'.format(req.host, req.port)\n            key = (req.host, req.port, req.ssl)\n            conn = Connection(self, key, proxy_req, transport, proto)\n            proxy_resp = proxy_req.send(conn.writer, conn.reader)\n            try:\n                resp = yield from proxy_resp.start(conn, True)\n            except:\n                proxy_resp.close()\n                conn.close()\n                raise\n            else:\n                if resp.status != 200:\n                    raise HttpProxyError(resp.status, resp.reason)\n                rawsock = transport.get_extra_info('socket', default=None)\n                if rawsock is None:\n                    raise RuntimeError(\n                        \"Transport does not expose socket instance\")\n                transport.pause_reading()\n                transport, proto = yield from self._loop.create_connection(\n                    self._factory, ssl=True, sock=rawsock,\n                    server_hostname=req.host, **kwargs)\n\n        return transport, proto",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 277,
                            "end_lineno": 284,
                            "parent": {
                                "file_name": "aiohttp/connector.py",
                                "type": "class",
                                "name": "ProxyConnector",
                                "content": "class ProxyConnector(TCPConnector):\n    \"\"\"Http Proxy connector.\"\"\"\n\n    def __init__(self, proxy, proxy_login=None, proxy_passwd=None,\n                 *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._proxy = proxy\n        self._basic_login = proxy_login\n        self._basic_passwd = proxy_passwd\n        assert proxy.startswith('http://'), (\n            \"Only http proxy supported\", proxy)\n\n    @property\n    def proxy(self):\n        return self._proxy\n\n    @asyncio.coroutine\n    def _create_connection(self, req, **kwargs):\n        proxy_req = ClientRequest(\n            'GET', self._proxy,\n            headers={'Host': req.host},\n            auth=aiohttp.BasicAuth(self._basic_login, self._basic_passwd),\n            loop=self._loop)\n        try:\n            transport, proto = yield from super()._create_connection(proxy_req)\n        except OSError as exc:\n            raise ProxyConnectionError(*exc.args) from exc\n        req.path = '{scheme}://{host}{path}'.format(scheme=req.scheme,\n                                                    host=req.host,\n                                                    path=req.path)\n        if 'AUTHORIZATION' in proxy_req.headers:\n            auth = proxy_req.headers['AUTHORIZATION']\n            del proxy_req.headers['AUTHORIZATION']\n            req.headers['PROXY-AUTHORIZATION'] = auth\n\n        if req.ssl:\n            # For HTTPS requests over HTTP proxy\n            # we must notify proxy to tunnel connection\n            # so we send CONNECT command:\n            #   CONNECT www.python.org:443 HTTP/1.1\n            #   Host: www.python.org\n            #\n            # next we must do TLS handshake and so on\n            # to do this we must wrap raw socket into secure one\n            # asyncio handles this perfectly\n            proxy_req.method = 'CONNECT'\n            proxy_req.path = '{}:{}'.format(req.host, req.port)\n            key = (req.host, req.port, req.ssl)\n            conn = Connection(self, key, proxy_req, transport, proto)\n            proxy_resp = proxy_req.send(conn.writer, conn.reader)\n            try:\n                resp = yield from proxy_resp.start(conn, True)\n            except:\n                proxy_resp.close()\n                conn.close()\n                raise\n            else:\n                if resp.status != 200:\n                    raise HttpProxyError(resp.status, resp.reason)\n                rawsock = transport.get_extra_info('socket', default=None)\n                if rawsock is None:\n                    raise RuntimeError(\n                        \"Transport does not expose socket instance\")\n                transport.pause_reading()\n                transport, proto = yield from self._loop.create_connection(\n                    self._factory, ssl=True, sock=rawsock,\n                    server_hostname=req.host, **kwargs)\n\n        return transport, proto",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 274,
                                "end_lineno": 342,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 292,
                            "length": 7
                        },
                        "new_range": {
                            "start": 292,
                            "length": 7
                        },
                        "section": "class ProxyConnector(TCPConnector):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        proxy_req = ClientRequest(",
                                "type": "context"
                            },
                            {
                                "content": "            'GET', self._proxy,",
                                "type": "context"
                            },
                            {
                                "content": "            headers={'Host': req.host},",
                                "type": "context"
                            },
                            {
                                "content": "            auth=aiohttp.BasicAuth(self._basic_login, self._basic_passwd),",
                                "type": "deleted"
                            },
                            {
                                "content": "            auth=self._proxy_auth,",
                                "type": "added"
                            },
                            {
                                "content": "            loop=self._loop)",
                                "type": "context"
                            },
                            {
                                "content": "        try:",
                                "type": "context"
                            },
                            {
                                "content": "            transport, proto = yield from super()._create_connection(proxy_req)",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "aiohttp/connector.py",
                            "type": "class",
                            "name": "ProxyConnector",
                            "content": "class ProxyConnector(TCPConnector):\n    \"\"\"Http Proxy connector.\"\"\"\n\n    def __init__(self, proxy, proxy_login=None, proxy_passwd=None,\n                 *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._proxy = proxy\n        self._basic_login = proxy_login\n        self._basic_passwd = proxy_passwd\n        assert proxy.startswith('http://'), (\n            \"Only http proxy supported\", proxy)\n\n    @property\n    def proxy(self):\n        return self._proxy\n\n    @asyncio.coroutine\n    def _create_connection(self, req, **kwargs):\n        proxy_req = ClientRequest(\n            'GET', self._proxy,\n            headers={'Host': req.host},\n            auth=aiohttp.BasicAuth(self._basic_login, self._basic_passwd),\n            loop=self._loop)\n        try:\n            transport, proto = yield from super()._create_connection(proxy_req)\n        except OSError as exc:\n            raise ProxyConnectionError(*exc.args) from exc\n        req.path = '{scheme}://{host}{path}'.format(scheme=req.scheme,\n                                                    host=req.host,\n                                                    path=req.path)\n        if 'AUTHORIZATION' in proxy_req.headers:\n            auth = proxy_req.headers['AUTHORIZATION']\n            del proxy_req.headers['AUTHORIZATION']\n            req.headers['PROXY-AUTHORIZATION'] = auth\n\n        if req.ssl:\n            # For HTTPS requests over HTTP proxy\n            # we must notify proxy to tunnel connection\n            # so we send CONNECT command:\n            #   CONNECT www.python.org:443 HTTP/1.1\n            #   Host: www.python.org\n            #\n            # next we must do TLS handshake and so on\n            # to do this we must wrap raw socket into secure one\n            # asyncio handles this perfectly\n            proxy_req.method = 'CONNECT'\n            proxy_req.path = '{}:{}'.format(req.host, req.port)\n            key = (req.host, req.port, req.ssl)\n            conn = Connection(self, key, proxy_req, transport, proto)\n            proxy_resp = proxy_req.send(conn.writer, conn.reader)\n            try:\n                resp = yield from proxy_resp.start(conn, True)\n            except:\n                proxy_resp.close()\n                conn.close()\n                raise\n            else:\n                if resp.status != 200:\n                    raise HttpProxyError(resp.status, resp.reason)\n                rawsock = transport.get_extra_info('socket', default=None)\n                if rawsock is None:\n                    raise RuntimeError(\n                        \"Transport does not expose socket instance\")\n                transport.pause_reading()\n                transport, proto = yield from self._loop.create_connection(\n                    self._factory, ssl=True, sock=rawsock,\n                    server_hostname=req.host, **kwargs)\n\n        return transport, proto",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 274,
                            "end_lineno": 342,
                            "parent": null
                        },
                        {
                            "file_name": "aiohttp/connector.py",
                            "type": "method",
                            "name": "ProxyConnector._create_connection",
                            "content": "class ProxyConnector(TCPConnector):\n    \"\"\"Http Proxy connector.\"\"\"\n\n    def __init__(self, proxy, proxy_login=None, proxy_passwd=None,\n                 *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._proxy = proxy\n        self._basic_login = proxy_login\n        self._basic_passwd = proxy_passwd\n        assert proxy.startswith('http://'), (\n            \"Only http proxy supported\", proxy)\n\n    @property\n    def proxy(self):\n        return self._proxy\n\n    @asyncio.coroutine\n    def _create_connection(self, req, **kwargs):\n        proxy_req = ClientRequest(\n            'GET', self._proxy,\n            headers={'Host': req.host},\n            auth=aiohttp.BasicAuth(self._basic_login, self._basic_passwd),\n            loop=self._loop)\n        try:\n            transport, proto = yield from super()._create_connection(proxy_req)\n        except OSError as exc:\n            raise ProxyConnectionError(*exc.args) from exc\n        req.path = '{scheme}://{host}{path}'.format(scheme=req.scheme,\n                                                    host=req.host,\n                                                    path=req.path)\n        if 'AUTHORIZATION' in proxy_req.headers:\n            auth = proxy_req.headers['AUTHORIZATION']\n            del proxy_req.headers['AUTHORIZATION']\n            req.headers['PROXY-AUTHORIZATION'] = auth\n\n        if req.ssl:\n            # For HTTPS requests over HTTP proxy\n            # we must notify proxy to tunnel connection\n            # so we send CONNECT command:\n            #   CONNECT www.python.org:443 HTTP/1.1\n            #   Host: www.python.org\n            #\n            # next we must do TLS handshake and so on\n            # to do this we must wrap raw socket into secure one\n            # asyncio handles this perfectly\n            proxy_req.method = 'CONNECT'\n            proxy_req.path = '{}:{}'.format(req.host, req.port)\n            key = (req.host, req.port, req.ssl)\n            conn = Connection(self, key, proxy_req, transport, proto)\n            proxy_resp = proxy_req.send(conn.writer, conn.reader)\n            try:\n                resp = yield from proxy_resp.start(conn, True)\n            except:\n                proxy_resp.close()\n                conn.close()\n                raise\n            else:\n                if resp.status != 200:\n                    raise HttpProxyError(resp.status, resp.reason)\n                rawsock = transport.get_extra_info('socket', default=None)\n                if rawsock is None:\n                    raise RuntimeError(\n                        \"Transport does not expose socket instance\")\n                transport.pause_reading()\n                transport, proto = yield from self._loop.create_connection(\n                    self._factory, ssl=True, sock=rawsock,\n                    server_hostname=req.host, **kwargs)\n\n        return transport, proto",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 291,
                            "end_lineno": 342,
                            "parent": {
                                "file_name": "aiohttp/connector.py",
                                "type": "class",
                                "name": "ProxyConnector",
                                "content": "class ProxyConnector(TCPConnector):\n    \"\"\"Http Proxy connector.\"\"\"\n\n    def __init__(self, proxy, proxy_login=None, proxy_passwd=None,\n                 *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._proxy = proxy\n        self._basic_login = proxy_login\n        self._basic_passwd = proxy_passwd\n        assert proxy.startswith('http://'), (\n            \"Only http proxy supported\", proxy)\n\n    @property\n    def proxy(self):\n        return self._proxy\n\n    @asyncio.coroutine\n    def _create_connection(self, req, **kwargs):\n        proxy_req = ClientRequest(\n            'GET', self._proxy,\n            headers={'Host': req.host},\n            auth=aiohttp.BasicAuth(self._basic_login, self._basic_passwd),\n            loop=self._loop)\n        try:\n            transport, proto = yield from super()._create_connection(proxy_req)\n        except OSError as exc:\n            raise ProxyConnectionError(*exc.args) from exc\n        req.path = '{scheme}://{host}{path}'.format(scheme=req.scheme,\n                                                    host=req.host,\n                                                    path=req.path)\n        if 'AUTHORIZATION' in proxy_req.headers:\n            auth = proxy_req.headers['AUTHORIZATION']\n            del proxy_req.headers['AUTHORIZATION']\n            req.headers['PROXY-AUTHORIZATION'] = auth\n\n        if req.ssl:\n            # For HTTPS requests over HTTP proxy\n            # we must notify proxy to tunnel connection\n            # so we send CONNECT command:\n            #   CONNECT www.python.org:443 HTTP/1.1\n            #   Host: www.python.org\n            #\n            # next we must do TLS handshake and so on\n            # to do this we must wrap raw socket into secure one\n            # asyncio handles this perfectly\n            proxy_req.method = 'CONNECT'\n            proxy_req.path = '{}:{}'.format(req.host, req.port)\n            key = (req.host, req.port, req.ssl)\n            conn = Connection(self, key, proxy_req, transport, proto)\n            proxy_resp = proxy_req.send(conn.writer, conn.reader)\n            try:\n                resp = yield from proxy_resp.start(conn, True)\n            except:\n                proxy_resp.close()\n                conn.close()\n                raise\n            else:\n                if resp.status != 200:\n                    raise HttpProxyError(resp.status, resp.reason)\n                rawsock = transport.get_extra_info('socket', default=None)\n                if rawsock is None:\n                    raise RuntimeError(\n                        \"Transport does not expose socket instance\")\n                transport.pause_reading()\n                transport, proto = yield from self._loop.create_connection(\n                    self._factory, ssl=True, sock=rawsock,\n                    server_hostname=req.host, **kwargs)\n\n        return transport, proto",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 274,
                                "end_lineno": 342,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "\"\"\"Tests of http client with custom Connector\"\"\"\n\nimport asyncio\nimport http.cookies\nimport gc\nimport time\nimport socket\nimport unittest\nfrom unittest import mock\n\nimport aiohttp\nfrom aiohttp import client\nfrom aiohttp import test_utils\nfrom aiohttp.client import ClientResponse, ClientRequest\nfrom aiohttp.connector import Connection\n\nfrom tests.test_client_functional import Functional\n\n\nclass HttpConnectionTests(unittest.TestCase):\n\n    def setUp(self):\n        self.key = object()\n        self.connector = mock.Mock()\n        self.request = mock.Mock()\n        self.transport = mock.Mock()\n        self.protocol = mock.Mock()\n\n    def test_del(self):\n        conn = Connection(\n            self.connector, self.key, self.request,\n            self.transport, self.protocol)\n        del conn\n        self.assertTrue(self.transport.close.called)\n\n    def test_close(self):\n        conn = Connection(\n            self.connector, self.key, self.request,\n            self.transport, self.protocol)\n        conn.close()\n        self.assertTrue(self.transport.close.called)\n        self.assertIsNone(conn._transport)\n\n    def test_release(self):\n        conn = Connection(\n            self.connector, self.key, self.request,\n            self.transport, self.protocol)\n        conn.release()\n        self.assertFalse(self.transport.close.called)\n        self.assertIsNone(conn._transport)\n        self.connector._release.assert_called_with(\n            self.key, self.request, self.transport, self.protocol)\n\n\nclass BaseConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n        self.transport = unittest.mock.Mock()\n        self.stream = aiohttp.StreamParser()\n        self.response = ClientResponse('get', 'http://python.org')\n\n    def tearDown(self):\n        self.loop.close()\n\n    def test_del(self):\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        transp = unittest.mock.Mock()\n        conn._conns['a'] = [(transp, 'proto', 123)]\n\n        conns_impl = conn._conns\n        del conn\n        self.assertFalse(conns_impl)\n        transp.close.assert_called_with()\n\n    def test_create_conn(self):\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        self.assertRaises(\n            NotImplementedError, conn._create_connection, object())\n\n    @unittest.mock.patch('aiohttp.connector.asyncio')\n    def test_ctor_loop(self, asyncio):\n        session = aiohttp.BaseConnector()\n        self.assertIs(session._loop, asyncio.get_event_loop.return_value)\n\n    def test_close(self):\n        tr = unittest.mock.Mock()\n\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        conn._conns[1] = [(tr, object(), object())]\n        conn.close()\n\n        self.assertFalse(conn._conns)\n        self.assertTrue(tr.close.called)\n\n    def test_get(self):\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        self.assertEqual(conn._get(1), (None, None))\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._conns[1] = [(tr, proto, time.time())]\n        self.assertEqual(conn._get(1), (tr, proto))\n\n    def test_get_expired(self):\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        self.assertEqual(conn._get(1), (None, None))\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._conns[1] = [(tr, proto, time.time()-1000)]\n        self.assertEqual(conn._get(1), (None, None))\n        self.assertEqual(conn._conns[1], [])\n\n    @mock.patch('aiohttp.connector.time')\n    def test_release(self, m_time):\n        m_time.time.return_value = 10\n\n        conn = aiohttp.BaseConnector(share_cookies=True, loop=self.loop)\n        conn._start_cleanup_task = unittest.mock.Mock()\n        req = unittest.mock.Mock()\n        resp = req.response = unittest.mock.Mock()\n        resp.message.should_close = False\n\n        cookies = resp.cookies = http.cookies.SimpleCookie()\n        cookies['c1'] = 'cookie1'\n        cookies['c2'] = 'cookie2'\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._release(1, req, tr, proto)\n        self.assertEqual(conn._conns[1][0], (tr, proto, 10))\n        self.assertEqual(conn.cookies, dict(cookies.items()))\n        self.assertTrue(conn._start_cleanup_task.called)\n\n    def test_release_close(self):\n        conn = aiohttp.BaseConnector(share_cookies=True, loop=self.loop)\n        req = unittest.mock.Mock()\n        resp = unittest.mock.Mock()\n        resp.message.should_close = True\n        req.response = resp\n\n        cookies = resp.cookies = http.cookies.SimpleCookie()\n        cookies['c1'] = 'cookie1'\n        cookies['c2'] = 'cookie2'\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._release(1, req, tr, proto)\n        self.assertFalse(conn._conns)\n        self.assertTrue(tr.close.called)\n\n    @mock.patch('aiohttp.connector.time')\n    def test_release_not_started(self, m_time):\n        m_time.time.return_value = 10\n\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        req = unittest.mock.Mock()\n        req.response = None\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._release(1, req, tr, proto)\n        self.assertEqual(conn._conns, {1: [(tr, proto, 10)]})\n        self.assertFalse(tr.close.called)\n\n    def test_release_not_opened(self):\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        req = unittest.mock.Mock()\n        req.response = unittest.mock.Mock()\n        req.response.message = None\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._release(1, req, tr, proto)\n        self.assertTrue(tr.close.called)\n\n    def test_connect(self):\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        proto.is_connected.return_value = True\n\n        class Req:\n            host = 'host'\n            port = 80\n            ssl = False\n\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        key = ('host', 80, False)\n        conn._conns[key] = [(tr, proto, time.time())]\n        conn._create_connection = unittest.mock.Mock()\n        conn._create_connection.return_value = asyncio.Future(loop=self.loop)\n        conn._create_connection.return_value.set_result((tr, proto))\n\n        connection = self.loop.run_until_complete(conn.connect(Req()))\n        self.assertFalse(conn._create_connection.called)\n        self.assertEqual(connection._transport, tr)\n        self.assertEqual(connection._protocol, proto)\n        self.assertIsInstance(connection, Connection)\n\n    def test_start_cleanup_task(self):\n        loop = unittest.mock.Mock()\n        conn = aiohttp.BaseConnector(loop=loop)\n        self.assertIsNone(conn._cleanup_handle)\n\n        conn._start_cleanup_task()\n        self.assertIsNotNone(conn._cleanup_handle)\n        loop.call_later.assert_called_with(\n            conn._keepalive_timeout, conn._cleanup)\n\n    @unittest.mock.patch('aiohttp.connector.time')\n    def test_cleanup(self, time):\n        time.time.return_value = 300\n\n        testset = {\n            1: [(unittest.mock.Mock(), unittest.mock.Mock(), 10),\n                (unittest.mock.Mock(), unittest.mock.Mock(), 300),\n                (None, unittest.mock.Mock(), 300)],\n        }\n        testset[1][0][1].is_connected.return_value = True\n        testset[1][1][1].is_connected.return_value = False\n\n        loop = unittest.mock.Mock()\n        conn = aiohttp.BaseConnector(loop=loop)\n        conn._conns = testset\n        existing_handle = conn._cleanup_handle = unittest.mock.Mock()\n\n        conn._cleanup()\n        self.assertTrue(existing_handle.cancel.called)\n        self.assertEqual(conn._conns, {})\n        self.assertIsNone(conn._cleanup_handle)\n\n        testset = {1: [(unittest.mock.Mock(), unittest.mock.Mock(), 300)]}\n        testset[1][0][1].is_connected.return_value = True\n\n        conn = aiohttp.BaseConnector(loop=loop)\n        conn._conns = testset\n        conn._cleanup()\n        self.assertEqual(conn._conns, testset)\n\n        self.assertIsNotNone(conn._cleanup_handle)\n\n    def test_tcp_connector_ctor(self):\n        conn = aiohttp.TCPConnector(loop=self.loop)\n        self.assertTrue(conn.verify_ssl)\n        self.assertFalse(conn.resolve)\n        self.assertEqual(conn.family, socket.AF_INET)\n        self.assertEqual(conn.resolved_hosts, {})\n\n\nclass HttpClientConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def test_tcp_connector(self):\n        with test_utils.run_server(self.loop, router=Functional) as httpd:\n            r = self.loop.run_until_complete(\n                client.request(\n                    'get', httpd.url('method', 'get'),\n                    connector=aiohttp.TCPConnector(loop=self.loop),\n                    loop=self.loop))\n            content = self.loop.run_until_complete(r.content.read())\n            content = content.decode()\n            self.assertEqual(r.status, 200)\n            r.close()\n\n    @unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'requires unix')\n    def test_unix_connector(self):\n        path = '/tmp/aiohttp_unix.sock'\n\n        connector = aiohttp.UnixConnector(path, loop=self.loop)\n        self.assertEqual(path, connector.path)\n\n        with test_utils.run_server(\n                self.loop, listen_addr=path, router=Functional) as httpd:\n            r = self.loop.run_until_complete(\n                client.request(\n                    'get', httpd.url('method', 'get'),\n                    connector=connector,\n                    loop=self.loop))\n            content = self.loop.run_until_complete(r.content.read())\n            content = content.decode()\n            self.assertEqual(r.status, 200)\n            r.close()\n\n\nclass ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth(None, None),\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_login='user', proxy_passwd='pass')\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n",
            "new_file_content": "\"\"\"Tests of http client with custom Connector\"\"\"\n\nimport asyncio\nimport http.cookies\nimport gc\nimport time\nimport socket\nimport unittest\nfrom unittest import mock\n\nimport aiohttp\nfrom aiohttp import client\nfrom aiohttp import test_utils\nfrom aiohttp.client import ClientResponse, ClientRequest\nfrom aiohttp.connector import Connection\n\nfrom tests.test_client_functional import Functional\n\n\nclass HttpConnectionTests(unittest.TestCase):\n\n    def setUp(self):\n        self.key = object()\n        self.connector = mock.Mock()\n        self.request = mock.Mock()\n        self.transport = mock.Mock()\n        self.protocol = mock.Mock()\n\n    def test_del(self):\n        conn = Connection(\n            self.connector, self.key, self.request,\n            self.transport, self.protocol)\n        del conn\n        self.assertTrue(self.transport.close.called)\n\n    def test_close(self):\n        conn = Connection(\n            self.connector, self.key, self.request,\n            self.transport, self.protocol)\n        conn.close()\n        self.assertTrue(self.transport.close.called)\n        self.assertIsNone(conn._transport)\n\n    def test_release(self):\n        conn = Connection(\n            self.connector, self.key, self.request,\n            self.transport, self.protocol)\n        conn.release()\n        self.assertFalse(self.transport.close.called)\n        self.assertIsNone(conn._transport)\n        self.connector._release.assert_called_with(\n            self.key, self.request, self.transport, self.protocol)\n\n\nclass BaseConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n        self.transport = unittest.mock.Mock()\n        self.stream = aiohttp.StreamParser()\n        self.response = ClientResponse('get', 'http://python.org')\n\n    def tearDown(self):\n        self.loop.close()\n\n    def test_del(self):\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        transp = unittest.mock.Mock()\n        conn._conns['a'] = [(transp, 'proto', 123)]\n\n        conns_impl = conn._conns\n        del conn\n        self.assertFalse(conns_impl)\n        transp.close.assert_called_with()\n\n    def test_create_conn(self):\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        self.assertRaises(\n            NotImplementedError, conn._create_connection, object())\n\n    @unittest.mock.patch('aiohttp.connector.asyncio')\n    def test_ctor_loop(self, asyncio):\n        session = aiohttp.BaseConnector()\n        self.assertIs(session._loop, asyncio.get_event_loop.return_value)\n\n    def test_close(self):\n        tr = unittest.mock.Mock()\n\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        conn._conns[1] = [(tr, object(), object())]\n        conn.close()\n\n        self.assertFalse(conn._conns)\n        self.assertTrue(tr.close.called)\n\n    def test_get(self):\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        self.assertEqual(conn._get(1), (None, None))\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._conns[1] = [(tr, proto, time.time())]\n        self.assertEqual(conn._get(1), (tr, proto))\n\n    def test_get_expired(self):\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        self.assertEqual(conn._get(1), (None, None))\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._conns[1] = [(tr, proto, time.time()-1000)]\n        self.assertEqual(conn._get(1), (None, None))\n        self.assertEqual(conn._conns[1], [])\n\n    @mock.patch('aiohttp.connector.time')\n    def test_release(self, m_time):\n        m_time.time.return_value = 10\n\n        conn = aiohttp.BaseConnector(share_cookies=True, loop=self.loop)\n        conn._start_cleanup_task = unittest.mock.Mock()\n        req = unittest.mock.Mock()\n        resp = req.response = unittest.mock.Mock()\n        resp.message.should_close = False\n\n        cookies = resp.cookies = http.cookies.SimpleCookie()\n        cookies['c1'] = 'cookie1'\n        cookies['c2'] = 'cookie2'\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._release(1, req, tr, proto)\n        self.assertEqual(conn._conns[1][0], (tr, proto, 10))\n        self.assertEqual(conn.cookies, dict(cookies.items()))\n        self.assertTrue(conn._start_cleanup_task.called)\n\n    def test_release_close(self):\n        conn = aiohttp.BaseConnector(share_cookies=True, loop=self.loop)\n        req = unittest.mock.Mock()\n        resp = unittest.mock.Mock()\n        resp.message.should_close = True\n        req.response = resp\n\n        cookies = resp.cookies = http.cookies.SimpleCookie()\n        cookies['c1'] = 'cookie1'\n        cookies['c2'] = 'cookie2'\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._release(1, req, tr, proto)\n        self.assertFalse(conn._conns)\n        self.assertTrue(tr.close.called)\n\n    @mock.patch('aiohttp.connector.time')\n    def test_release_not_started(self, m_time):\n        m_time.time.return_value = 10\n\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        req = unittest.mock.Mock()\n        req.response = None\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._release(1, req, tr, proto)\n        self.assertEqual(conn._conns, {1: [(tr, proto, 10)]})\n        self.assertFalse(tr.close.called)\n\n    def test_release_not_opened(self):\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        req = unittest.mock.Mock()\n        req.response = unittest.mock.Mock()\n        req.response.message = None\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._release(1, req, tr, proto)\n        self.assertTrue(tr.close.called)\n\n    def test_connect(self):\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        proto.is_connected.return_value = True\n\n        class Req:\n            host = 'host'\n            port = 80\n            ssl = False\n\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        key = ('host', 80, False)\n        conn._conns[key] = [(tr, proto, time.time())]\n        conn._create_connection = unittest.mock.Mock()\n        conn._create_connection.return_value = asyncio.Future(loop=self.loop)\n        conn._create_connection.return_value.set_result((tr, proto))\n\n        connection = self.loop.run_until_complete(conn.connect(Req()))\n        self.assertFalse(conn._create_connection.called)\n        self.assertEqual(connection._transport, tr)\n        self.assertEqual(connection._protocol, proto)\n        self.assertIsInstance(connection, Connection)\n\n    def test_start_cleanup_task(self):\n        loop = unittest.mock.Mock()\n        conn = aiohttp.BaseConnector(loop=loop)\n        self.assertIsNone(conn._cleanup_handle)\n\n        conn._start_cleanup_task()\n        self.assertIsNotNone(conn._cleanup_handle)\n        loop.call_later.assert_called_with(\n            conn._keepalive_timeout, conn._cleanup)\n\n    @unittest.mock.patch('aiohttp.connector.time')\n    def test_cleanup(self, time):\n        time.time.return_value = 300\n\n        testset = {\n            1: [(unittest.mock.Mock(), unittest.mock.Mock(), 10),\n                (unittest.mock.Mock(), unittest.mock.Mock(), 300),\n                (None, unittest.mock.Mock(), 300)],\n        }\n        testset[1][0][1].is_connected.return_value = True\n        testset[1][1][1].is_connected.return_value = False\n\n        loop = unittest.mock.Mock()\n        conn = aiohttp.BaseConnector(loop=loop)\n        conn._conns = testset\n        existing_handle = conn._cleanup_handle = unittest.mock.Mock()\n\n        conn._cleanup()\n        self.assertTrue(existing_handle.cancel.called)\n        self.assertEqual(conn._conns, {})\n        self.assertIsNone(conn._cleanup_handle)\n\n        testset = {1: [(unittest.mock.Mock(), unittest.mock.Mock(), 300)]}\n        testset[1][0][1].is_connected.return_value = True\n\n        conn = aiohttp.BaseConnector(loop=loop)\n        conn._conns = testset\n        conn._cleanup()\n        self.assertEqual(conn._conns, testset)\n\n        self.assertIsNotNone(conn._cleanup_handle)\n\n    def test_tcp_connector_ctor(self):\n        conn = aiohttp.TCPConnector(loop=self.loop)\n        self.assertTrue(conn.verify_ssl)\n        self.assertFalse(conn.resolve)\n        self.assertEqual(conn.family, socket.AF_INET)\n        self.assertEqual(conn.resolved_hosts, {})\n\n\nclass HttpClientConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def test_tcp_connector(self):\n        with test_utils.run_server(self.loop, router=Functional) as httpd:\n            r = self.loop.run_until_complete(\n                client.request(\n                    'get', httpd.url('method', 'get'),\n                    connector=aiohttp.TCPConnector(loop=self.loop),\n                    loop=self.loop))\n            content = self.loop.run_until_complete(r.content.read())\n            content = content.decode()\n            self.assertEqual(r.status, 200)\n            r.close()\n\n    @unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'requires unix')\n    def test_unix_connector(self):\n        path = '/tmp/aiohttp_unix.sock'\n\n        connector = aiohttp.UnixConnector(path, loop=self.loop)\n        self.assertEqual(path, connector.path)\n\n        with test_utils.run_server(\n                self.loop, listen_addr=path, router=Functional) as httpd:\n            r = self.loop.run_until_complete(\n                client.request(\n                    'get', httpd.url('method', 'get'),\n                    connector=connector,\n                    loop=self.loop))\n            content = self.loop.run_until_complete(r.content.read())\n            content = content.decode()\n            self.assertEqual(r.status, 200)\n            r.close()\n\n\nclass ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=None,\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_auth(self):\n        with self.assertRaisesRegex(AssertionError,\n                                    \"must be None or BasicAuth\"):\n            aiohttp.ProxyConnector('http://proxy.example.com',\n                                   proxy_auth=('user', 'pass'),\n                                   loop=unittest.mock.Mock())\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_proxy_override_auth(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n\n        loop_mock = unittest.mock.Mock()\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com',\n            proxy_auth=aiohttp.BasicAuth(None, None),\n            loop=loop_mock)\n\n        def check_proxy_req(*args, **kw):\n            proxy_req = ClientRequest(*args, **kw)\n            self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n            return proxy_req\n\n        ClientRequestMock.side_effect = check_proxy_req\n        self.loop.run_until_complete(connector._create_connection(req))\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_auth=aiohttp.BasicAuth('user', 'pass'))\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth('user', 'pass'),\n            loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://user:pass@proxy.example.com',\n            auth=None, loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n",
            "header": {
                "file": {
                    "path": "tests/test_connector.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "dfe9587a",
                "new_commit_hash": "f89294ba",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/tests/test_connector.py"
            },
            "plus_file": {
                "path": "b/tests/test_connector.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 346,
                            "length": 10
                        },
                        "new_range": {
                            "start": 346,
                            "length": 38
                        },
                        "section": "class ProxyConnectorTests(unittest.TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        ClientRequestMock.assert_called_with(",
                                "type": "context"
                            },
                            {
                                "content": "            'GET', 'http://proxy.example.com',",
                                "type": "context"
                            },
                            {
                                "content": "            auth=aiohttp.BasicAuth(None, None),",
                                "type": "deleted"
                            },
                            {
                                "content": "            auth=None,",
                                "type": "added"
                            },
                            {
                                "content": "            headers={'Host': 'www.python.org'},",
                                "type": "context"
                            },
                            {
                                "content": "            loop=loop_mock)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_proxy_auth(self):",
                                "type": "added"
                            },
                            {
                                "content": "        with self.assertRaisesRegex(AssertionError,",
                                "type": "added"
                            },
                            {
                                "content": "                                    \"must be None or BasicAuth\"):",
                                "type": "added"
                            },
                            {
                                "content": "            aiohttp.ProxyConnector('http://proxy.example.com',",
                                "type": "added"
                            },
                            {
                                "content": "                                   proxy_auth=('user', 'pass'),",
                                "type": "added"
                            },
                            {
                                "content": "                                   loop=unittest.mock.Mock())",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "    @unittest.mock.patch('aiohttp.connector.ClientRequest')",
                                "type": "added"
                            },
                            {
                                "content": "    def test_proxy_override_auth(self, ClientRequestMock):",
                                "type": "added"
                            },
                            {
                                "content": "        req = ClientRequest('GET', 'http://www.python.org')",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "        loop_mock = unittest.mock.Mock()",
                                "type": "added"
                            },
                            {
                                "content": "        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()",
                                "type": "added"
                            },
                            {
                                "content": "        self._fake_coroutine(loop_mock.create_connection, (tr, proto))",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "        connector = aiohttp.ProxyConnector(",
                                "type": "added"
                            },
                            {
                                "content": "            'http://user:pass@proxy.example.com',",
                                "type": "added"
                            },
                            {
                                "content": "            proxy_auth=aiohttp.BasicAuth(None, None),",
                                "type": "added"
                            },
                            {
                                "content": "            loop=loop_mock)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "        def check_proxy_req(*args, **kw):",
                                "type": "added"
                            },
                            {
                                "content": "            proxy_req = ClientRequest(*args, **kw)",
                                "type": "added"
                            },
                            {
                                "content": "            self.assertNotIn('AUTHORIZATION', proxy_req.headers)",
                                "type": "added"
                            },
                            {
                                "content": "            return proxy_req",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "        ClientRequestMock.side_effect = check_proxy_req",
                                "type": "added"
                            },
                            {
                                "content": "        self.loop.run_until_complete(connector._create_connection(req))",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "    def test_proxy_connection_error(self):",
                                "type": "context"
                            },
                            {
                                "content": "        connector = aiohttp.ProxyConnector('http://proxy.example.com',",
                                "type": "context"
                            },
                            {
                                "content": "                                           loop=self.loop)",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "tests/test_connector.py",
                            "type": "class",
                            "name": "ProxyConnectorTests",
                            "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth(None, None),\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_login='user', proxy_passwd='pass')\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 291,
                            "end_lineno": 542,
                            "parent": null
                        },
                        {
                            "file_name": "tests/test_connector.py",
                            "type": "method",
                            "name": "ProxyConnectorTests.test_connect",
                            "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth(None, None),\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_login='user', proxy_passwd='pass')\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 324,
                            "end_lineno": 351,
                            "parent": {
                                "file_name": "tests/test_connector.py",
                                "type": "class",
                                "name": "ProxyConnectorTests",
                                "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth(None, None),\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_login='user', proxy_passwd='pass')\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 291,
                                "end_lineno": 542,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [
                        {
                            "file_name": "tests/test_connector.py",
                            "type": "method",
                            "name": "ProxyConnectorTests.test_proxy_override_auth",
                            "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=None,\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_auth(self):\n        with self.assertRaisesRegex(AssertionError,\n                                    \"must be None or BasicAuth\"):\n            aiohttp.ProxyConnector('http://proxy.example.com',\n                                   proxy_auth=('user', 'pass'),\n                                   loop=unittest.mock.Mock())\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_proxy_override_auth(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n\n        loop_mock = unittest.mock.Mock()\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com',\n            proxy_auth=aiohttp.BasicAuth(None, None),\n            loop=loop_mock)\n\n        def check_proxy_req(*args, **kw):\n            proxy_req = ClientRequest(*args, **kw)\n            self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n            return proxy_req\n\n        ClientRequestMock.side_effect = check_proxy_req\n        self.loop.run_until_complete(connector._create_connection(req))\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_auth=aiohttp.BasicAuth('user', 'pass'))\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth('user', 'pass'),\n            loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://user:pass@proxy.example.com',\n            auth=None, loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 361,
                            "end_lineno": 379,
                            "parent": {
                                "file_name": "tests/test_connector.py",
                                "type": "class",
                                "name": "ProxyConnectorTests",
                                "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=None,\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_auth(self):\n        with self.assertRaisesRegex(AssertionError,\n                                    \"must be None or BasicAuth\"):\n            aiohttp.ProxyConnector('http://proxy.example.com',\n                                   proxy_auth=('user', 'pass'),\n                                   loop=unittest.mock.Mock())\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_proxy_override_auth(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n\n        loop_mock = unittest.mock.Mock()\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com',\n            proxy_auth=aiohttp.BasicAuth(None, None),\n            loop=loop_mock)\n\n        def check_proxy_req(*args, **kw):\n            proxy_req = ClientRequest(*args, **kw)\n            self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n            return proxy_req\n\n        ClientRequestMock.side_effect = check_proxy_req\n        self.loop.run_until_complete(connector._create_connection(req))\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_auth=aiohttp.BasicAuth('user', 'pass'))\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth('user', 'pass'),\n            loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://user:pass@proxy.example.com',\n            auth=None, loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 291,
                                "end_lineno": 579,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "tests/test_connector.py",
                            "type": "method",
                            "name": "ProxyConnectorTests.test_proxy_auth",
                            "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=None,\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_auth(self):\n        with self.assertRaisesRegex(AssertionError,\n                                    \"must be None or BasicAuth\"):\n            aiohttp.ProxyConnector('http://proxy.example.com',\n                                   proxy_auth=('user', 'pass'),\n                                   loop=unittest.mock.Mock())\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_proxy_override_auth(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n\n        loop_mock = unittest.mock.Mock()\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com',\n            proxy_auth=aiohttp.BasicAuth(None, None),\n            loop=loop_mock)\n\n        def check_proxy_req(*args, **kw):\n            proxy_req = ClientRequest(*args, **kw)\n            self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n            return proxy_req\n\n        ClientRequestMock.side_effect = check_proxy_req\n        self.loop.run_until_complete(connector._create_connection(req))\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_auth=aiohttp.BasicAuth('user', 'pass'))\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth('user', 'pass'),\n            loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://user:pass@proxy.example.com',\n            auth=None, loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 353,
                            "end_lineno": 358,
                            "parent": {
                                "file_name": "tests/test_connector.py",
                                "type": "class",
                                "name": "ProxyConnectorTests",
                                "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=None,\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_auth(self):\n        with self.assertRaisesRegex(AssertionError,\n                                    \"must be None or BasicAuth\"):\n            aiohttp.ProxyConnector('http://proxy.example.com',\n                                   proxy_auth=('user', 'pass'),\n                                   loop=unittest.mock.Mock())\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_proxy_override_auth(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n\n        loop_mock = unittest.mock.Mock()\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com',\n            proxy_auth=aiohttp.BasicAuth(None, None),\n            loop=loop_mock)\n\n        def check_proxy_req(*args, **kw):\n            proxy_req = ClientRequest(*args, **kw)\n            self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n            return proxy_req\n\n        ClientRequestMock.side_effect = check_proxy_req\n        self.loop.run_until_complete(connector._create_connection(req))\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_auth=aiohttp.BasicAuth('user', 'pass'))\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth('user', 'pass'),\n            loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://user:pass@proxy.example.com',\n            auth=None, loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 291,
                                "end_lineno": 579,
                                "parent": null
                            }
                        }
                    ],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 374,
                            "length": 7
                        },
                        "new_range": {
                            "start": 402,
                            "length": 7
                        },
                        "section": "class ProxyConnectorTests(unittest.TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        loop_mock = unittest.mock.Mock()",
                                "type": "context"
                            },
                            {
                                "content": "        connector = aiohttp.ProxyConnector(",
                                "type": "context"
                            },
                            {
                                "content": "            'http://proxy.example.com', loop=loop_mock,",
                                "type": "context"
                            },
                            {
                                "content": "            proxy_login='user', proxy_passwd='pass')",
                                "type": "deleted"
                            },
                            {
                                "content": "            proxy_auth=aiohttp.BasicAuth('user', 'pass'))",
                                "type": "added"
                            },
                            {
                                "content": "        connector._resolve_host = resolve_mock = unittest.mock.Mock()",
                                "type": "context"
                            },
                            {
                                "content": "        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "tests/test_connector.py",
                            "type": "method",
                            "name": "ProxyConnectorTests.test_auth",
                            "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth(None, None),\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_login='user', proxy_passwd='pass')\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 367,
                            "end_lineno": 393,
                            "parent": {
                                "file_name": "tests/test_connector.py",
                                "type": "class",
                                "name": "ProxyConnectorTests",
                                "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth(None, None),\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_login='user', proxy_passwd='pass')\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 291,
                                "end_lineno": 542,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "tests/test_connector.py",
                            "type": "class",
                            "name": "ProxyConnectorTests",
                            "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth(None, None),\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_login='user', proxy_passwd='pass')\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 291,
                            "end_lineno": 542,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 392,
                            "length": 6
                        },
                        "new_range": {
                            "start": 420,
                            "length": 11
                        },
                        "section": "class ProxyConnectorTests(unittest.TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        self.assertNotIn('AUTHORIZATION', proxy_req.headers)",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        ClientRequestMock.assert_called_with(",
                                "type": "added"
                            },
                            {
                                "content": "            'GET', 'http://proxy.example.com',",
                                "type": "added"
                            },
                            {
                                "content": "            auth=aiohttp.BasicAuth('user', 'pass'),",
                                "type": "added"
                            },
                            {
                                "content": "            loop=unittest.mock.ANY, headers=unittest.mock.ANY)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "    @unittest.mock.patch('aiohttp.connector.ClientRequest')",
                                "type": "context"
                            },
                            {
                                "content": "    def test_auth_from_url(self, ClientRequestMock):",
                                "type": "context"
                            },
                            {
                                "content": "        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "tests/test_connector.py",
                            "type": "method",
                            "name": "ProxyConnectorTests.test_auth",
                            "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=None,\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_auth(self):\n        with self.assertRaisesRegex(AssertionError,\n                                    \"must be None or BasicAuth\"):\n            aiohttp.ProxyConnector('http://proxy.example.com',\n                                   proxy_auth=('user', 'pass'),\n                                   loop=unittest.mock.Mock())\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_proxy_override_auth(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n\n        loop_mock = unittest.mock.Mock()\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com',\n            proxy_auth=aiohttp.BasicAuth(None, None),\n            loop=loop_mock)\n\n        def check_proxy_req(*args, **kw):\n            proxy_req = ClientRequest(*args, **kw)\n            self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n            return proxy_req\n\n        ClientRequestMock.side_effect = check_proxy_req\n        self.loop.run_until_complete(connector._create_connection(req))\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_auth=aiohttp.BasicAuth('user', 'pass'))\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth('user', 'pass'),\n            loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://user:pass@proxy.example.com',\n            auth=None, loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 395,
                            "end_lineno": 426,
                            "parent": {
                                "file_name": "tests/test_connector.py",
                                "type": "class",
                                "name": "ProxyConnectorTests",
                                "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=None,\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_auth(self):\n        with self.assertRaisesRegex(AssertionError,\n                                    \"must be None or BasicAuth\"):\n            aiohttp.ProxyConnector('http://proxy.example.com',\n                                   proxy_auth=('user', 'pass'),\n                                   loop=unittest.mock.Mock())\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_proxy_override_auth(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n\n        loop_mock = unittest.mock.Mock()\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com',\n            proxy_auth=aiohttp.BasicAuth(None, None),\n            loop=loop_mock)\n\n        def check_proxy_req(*args, **kw):\n            proxy_req = ClientRequest(*args, **kw)\n            self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n            return proxy_req\n\n        ClientRequestMock.side_effect = check_proxy_req\n        self.loop.run_until_complete(connector._create_connection(req))\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_auth=aiohttp.BasicAuth('user', 'pass'))\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth('user', 'pass'),\n            loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://user:pass@proxy.example.com',\n            auth=None, loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 291,
                                "end_lineno": 579,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "tests/test_connector.py",
                            "type": "class",
                            "name": "ProxyConnectorTests",
                            "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=None,\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_auth(self):\n        with self.assertRaisesRegex(AssertionError,\n                                    \"must be None or BasicAuth\"):\n            aiohttp.ProxyConnector('http://proxy.example.com',\n                                   proxy_auth=('user', 'pass'),\n                                   loop=unittest.mock.Mock())\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_proxy_override_auth(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n\n        loop_mock = unittest.mock.Mock()\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com',\n            proxy_auth=aiohttp.BasicAuth(None, None),\n            loop=loop_mock)\n\n        def check_proxy_req(*args, **kw):\n            proxy_req = ClientRequest(*args, **kw)\n            self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n            return proxy_req\n\n        ClientRequestMock.side_effect = check_proxy_req\n        self.loop.run_until_complete(connector._create_connection(req))\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_auth=aiohttp.BasicAuth('user', 'pass'))\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth('user', 'pass'),\n            loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://user:pass@proxy.example.com',\n            auth=None, loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 291,
                            "end_lineno": 579,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 419,
                            "length": 6
                        },
                        "new_range": {
                            "start": 452,
                            "length": 10
                        },
                        "section": "class ProxyConnectorTests(unittest.TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        self.assertNotIn('AUTHORIZATION', proxy_req.headers)",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        ClientRequestMock.assert_called_with(",
                                "type": "added"
                            },
                            {
                                "content": "            'GET', 'http://user:pass@proxy.example.com',",
                                "type": "added"
                            },
                            {
                                "content": "            auth=None, loop=unittest.mock.ANY, headers=unittest.mock.ANY)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "    @unittest.mock.patch('aiohttp.connector.ClientRequest')",
                                "type": "context"
                            },
                            {
                                "content": "    def test_auth__not_modifying_request(self, ClientRequestMock):",
                                "type": "context"
                            },
                            {
                                "content": "        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "tests/test_connector.py",
                            "type": "class",
                            "name": "ProxyConnectorTests",
                            "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=None,\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_auth(self):\n        with self.assertRaisesRegex(AssertionError,\n                                    \"must be None or BasicAuth\"):\n            aiohttp.ProxyConnector('http://proxy.example.com',\n                                   proxy_auth=('user', 'pass'),\n                                   loop=unittest.mock.Mock())\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_proxy_override_auth(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n\n        loop_mock = unittest.mock.Mock()\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com',\n            proxy_auth=aiohttp.BasicAuth(None, None),\n            loop=loop_mock)\n\n        def check_proxy_req(*args, **kw):\n            proxy_req = ClientRequest(*args, **kw)\n            self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n            return proxy_req\n\n        ClientRequestMock.side_effect = check_proxy_req\n        self.loop.run_until_complete(connector._create_connection(req))\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_auth=aiohttp.BasicAuth('user', 'pass'))\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth('user', 'pass'),\n            loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://user:pass@proxy.example.com',\n            auth=None, loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 291,
                            "end_lineno": 579,
                            "parent": null
                        },
                        {
                            "file_name": "tests/test_connector.py",
                            "type": "method",
                            "name": "ProxyConnectorTests.test_auth_from_url",
                            "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=None,\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_auth(self):\n        with self.assertRaisesRegex(AssertionError,\n                                    \"must be None or BasicAuth\"):\n            aiohttp.ProxyConnector('http://proxy.example.com',\n                                   proxy_auth=('user', 'pass'),\n                                   loop=unittest.mock.Mock())\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_proxy_override_auth(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n\n        loop_mock = unittest.mock.Mock()\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com',\n            proxy_auth=aiohttp.BasicAuth(None, None),\n            loop=loop_mock)\n\n        def check_proxy_req(*args, **kw):\n            proxy_req = ClientRequest(*args, **kw)\n            self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n            return proxy_req\n\n        ClientRequestMock.side_effect = check_proxy_req\n        self.loop.run_until_complete(connector._create_connection(req))\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_auth=aiohttp.BasicAuth('user', 'pass'))\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth('user', 'pass'),\n            loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://user:pass@proxy.example.com',\n            auth=None, loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 429,
                            "end_lineno": 457,
                            "parent": {
                                "file_name": "tests/test_connector.py",
                                "type": "class",
                                "name": "ProxyConnectorTests",
                                "content": "class ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=None,\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_auth(self):\n        with self.assertRaisesRegex(AssertionError,\n                                    \"must be None or BasicAuth\"):\n            aiohttp.ProxyConnector('http://proxy.example.com',\n                                   proxy_auth=('user', 'pass'),\n                                   loop=unittest.mock.Mock())\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_proxy_override_auth(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n\n        loop_mock = unittest.mock.Mock()\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com',\n            proxy_auth=aiohttp.BasicAuth(None, None),\n            loop=loop_mock)\n\n        def check_proxy_req(*args, **kw):\n            proxy_req = ClientRequest(*args, **kw)\n            self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n            return proxy_req\n\n        ClientRequestMock.side_effect = check_proxy_req\n        self.loop.run_until_complete(connector._create_connection(req))\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_auth=aiohttp.BasicAuth('user', 'pass'))\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth('user', 'pass'),\n            loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://user:pass@proxy.example.com',\n            auth=None, loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 291,
                                "end_lineno": 579,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "750a09537324940f2b29cf62e023a94b9a1a8709^",
    "new_commit_hash": "750a09537324940f2b29cf62e023a94b9a1a8709",
    "commit_message": "ProxyConnector authorization parameters changed",
    "commit_date": "2014-07-04T14:54:42+03:00",
    "metadata": {}
}
{
    "repo_name": "aiohttp",
    "new_commit_hash": "750a09537324940f2b29cf62e023a94b9a1a8709",
    "test_file_codes": [
        "\"\"\"Tests of http client with custom Connector\"\"\"\n\nimport asyncio\nimport http.cookies\nimport gc\nimport time\nimport socket\nimport unittest\nfrom unittest import mock\n\nimport aiohttp\nfrom aiohttp import client\nfrom aiohttp import test_utils\nfrom aiohttp.client import ClientResponse, ClientRequest\nfrom aiohttp.connector import Connection\n\nfrom tests.test_client_functional import Functional\n\n\nclass HttpConnectionTests(unittest.TestCase):\n\n    def setUp(self):\n        self.key = object()\n        self.connector = mock.Mock()\n        self.request = mock.Mock()\n        self.transport = mock.Mock()\n        self.protocol = mock.Mock()\n\n    def test_del(self):\n        conn = Connection(\n            self.connector, self.key, self.request,\n            self.transport, self.protocol)\n        del conn\n        self.assertTrue(self.transport.close.called)\n\n    def test_close(self):\n        conn = Connection(\n            self.connector, self.key, self.request,\n            self.transport, self.protocol)\n        conn.close()\n        self.assertTrue(self.transport.close.called)\n        self.assertIsNone(conn._transport)\n\n    def test_release(self):\n        conn = Connection(\n            self.connector, self.key, self.request,\n            self.transport, self.protocol)\n        conn.release()\n        self.assertFalse(self.transport.close.called)\n        self.assertIsNone(conn._transport)\n        self.connector._release.assert_called_with(\n            self.key, self.request, self.transport, self.protocol)\n\n\nclass BaseConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n        self.transport = unittest.mock.Mock()\n        self.stream = aiohttp.StreamParser()\n        self.response = ClientResponse('get', 'http://python.org')\n\n    def tearDown(self):\n        self.loop.close()\n\n    def test_del(self):\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        transp = unittest.mock.Mock()\n        conn._conns['a'] = [(transp, 'proto', 123)]\n\n        conns_impl = conn._conns\n        del conn\n        self.assertFalse(conns_impl)\n        transp.close.assert_called_with()\n\n    def test_create_conn(self):\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        self.assertRaises(\n            NotImplementedError, conn._create_connection, object())\n\n    @unittest.mock.patch('aiohttp.connector.asyncio')\n    def test_ctor_loop(self, asyncio):\n        session = aiohttp.BaseConnector()\n        self.assertIs(session._loop, asyncio.get_event_loop.return_value)\n\n    def test_close(self):\n        tr = unittest.mock.Mock()\n\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        conn._conns[1] = [(tr, object(), object())]\n        conn.close()\n\n        self.assertFalse(conn._conns)\n        self.assertTrue(tr.close.called)\n\n    def test_get(self):\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        self.assertEqual(conn._get(1), (None, None))\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._conns[1] = [(tr, proto, time.time())]\n        self.assertEqual(conn._get(1), (tr, proto))\n\n    def test_get_expired(self):\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        self.assertEqual(conn._get(1), (None, None))\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._conns[1] = [(tr, proto, time.time()-1000)]\n        self.assertEqual(conn._get(1), (None, None))\n        self.assertEqual(conn._conns[1], [])\n\n    @mock.patch('aiohttp.connector.time')\n    def test_release(self, m_time):\n        m_time.time.return_value = 10\n\n        conn = aiohttp.BaseConnector(share_cookies=True, loop=self.loop)\n        conn._start_cleanup_task = unittest.mock.Mock()\n        req = unittest.mock.Mock()\n        resp = req.response = unittest.mock.Mock()\n        resp.message.should_close = False\n\n        cookies = resp.cookies = http.cookies.SimpleCookie()\n        cookies['c1'] = 'cookie1'\n        cookies['c2'] = 'cookie2'\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._release(1, req, tr, proto)\n        self.assertEqual(conn._conns[1][0], (tr, proto, 10))\n        self.assertEqual(conn.cookies, dict(cookies.items()))\n        self.assertTrue(conn._start_cleanup_task.called)\n\n    def test_release_close(self):\n        conn = aiohttp.BaseConnector(share_cookies=True, loop=self.loop)\n        req = unittest.mock.Mock()\n        resp = unittest.mock.Mock()\n        resp.message.should_close = True\n        req.response = resp\n\n        cookies = resp.cookies = http.cookies.SimpleCookie()\n        cookies['c1'] = 'cookie1'\n        cookies['c2'] = 'cookie2'\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._release(1, req, tr, proto)\n        self.assertFalse(conn._conns)\n        self.assertTrue(tr.close.called)\n\n    @mock.patch('aiohttp.connector.time')\n    def test_release_not_started(self, m_time):\n        m_time.time.return_value = 10\n\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        req = unittest.mock.Mock()\n        req.response = None\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._release(1, req, tr, proto)\n        self.assertEqual(conn._conns, {1: [(tr, proto, 10)]})\n        self.assertFalse(tr.close.called)\n\n    def test_release_not_opened(self):\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        req = unittest.mock.Mock()\n        req.response = unittest.mock.Mock()\n        req.response.message = None\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        conn._release(1, req, tr, proto)\n        self.assertTrue(tr.close.called)\n\n    def test_connect(self):\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        proto.is_connected.return_value = True\n\n        class Req:\n            host = 'host'\n            port = 80\n            ssl = False\n\n        conn = aiohttp.BaseConnector(loop=self.loop)\n        key = ('host', 80, False)\n        conn._conns[key] = [(tr, proto, time.time())]\n        conn._create_connection = unittest.mock.Mock()\n        conn._create_connection.return_value = asyncio.Future(loop=self.loop)\n        conn._create_connection.return_value.set_result((tr, proto))\n\n        connection = self.loop.run_until_complete(conn.connect(Req()))\n        self.assertFalse(conn._create_connection.called)\n        self.assertEqual(connection._transport, tr)\n        self.assertEqual(connection._protocol, proto)\n        self.assertIsInstance(connection, Connection)\n\n    def test_start_cleanup_task(self):\n        loop = unittest.mock.Mock()\n        conn = aiohttp.BaseConnector(loop=loop)\n        self.assertIsNone(conn._cleanup_handle)\n\n        conn._start_cleanup_task()\n        self.assertIsNotNone(conn._cleanup_handle)\n        loop.call_later.assert_called_with(\n            conn._keepalive_timeout, conn._cleanup)\n\n    @unittest.mock.patch('aiohttp.connector.time')\n    def test_cleanup(self, time):\n        time.time.return_value = 300\n\n        testset = {\n            1: [(unittest.mock.Mock(), unittest.mock.Mock(), 10),\n                (unittest.mock.Mock(), unittest.mock.Mock(), 300),\n                (None, unittest.mock.Mock(), 300)],\n        }\n        testset[1][0][1].is_connected.return_value = True\n        testset[1][1][1].is_connected.return_value = False\n\n        loop = unittest.mock.Mock()\n        conn = aiohttp.BaseConnector(loop=loop)\n        conn._conns = testset\n        existing_handle = conn._cleanup_handle = unittest.mock.Mock()\n\n        conn._cleanup()\n        self.assertTrue(existing_handle.cancel.called)\n        self.assertEqual(conn._conns, {})\n        self.assertIsNone(conn._cleanup_handle)\n\n        testset = {1: [(unittest.mock.Mock(), unittest.mock.Mock(), 300)]}\n        testset[1][0][1].is_connected.return_value = True\n\n        conn = aiohttp.BaseConnector(loop=loop)\n        conn._conns = testset\n        conn._cleanup()\n        self.assertEqual(conn._conns, testset)\n\n        self.assertIsNotNone(conn._cleanup_handle)\n\n    def test_tcp_connector_ctor(self):\n        conn = aiohttp.TCPConnector(loop=self.loop)\n        self.assertTrue(conn.verify_ssl)\n        self.assertFalse(conn.resolve)\n        self.assertEqual(conn.family, socket.AF_INET)\n        self.assertEqual(conn.resolved_hosts, {})\n\n\nclass HttpClientConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def test_tcp_connector(self):\n        with test_utils.run_server(self.loop, router=Functional) as httpd:\n            r = self.loop.run_until_complete(\n                client.request(\n                    'get', httpd.url('method', 'get'),\n                    connector=aiohttp.TCPConnector(loop=self.loop),\n                    loop=self.loop))\n            content = self.loop.run_until_complete(r.content.read())\n            content = content.decode()\n            self.assertEqual(r.status, 200)\n            r.close()\n\n    @unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'requires unix')\n    def test_unix_connector(self):\n        path = '/tmp/aiohttp_unix.sock'\n\n        connector = aiohttp.UnixConnector(path, loop=self.loop)\n        self.assertEqual(path, connector.path)\n\n        with test_utils.run_server(\n                self.loop, listen_addr=path, router=Functional) as httpd:\n            r = self.loop.run_until_complete(\n                client.request(\n                    'get', httpd.url('method', 'get'),\n                    connector=connector,\n                    loop=self.loop))\n            content = self.loop.run_until_complete(r.content.read())\n            content = content.decode()\n            self.assertEqual(r.status, 200)\n            r.close()\n\n\nclass ProxyConnectorTests(unittest.TestCase):\n\n    def setUp(self):\n        self.loop = asyncio.new_event_loop()\n        asyncio.set_event_loop(None)\n\n    def tearDown(self):\n        # just in case if we have transport close callbacks\n        test_utils.run_briefly(self.loop)\n\n        self.loop.close()\n        gc.collect()\n\n    def _fake_coroutine(self, mock, return_value):\n\n        def coro(*args, **kw):\n            if isinstance(return_value, Exception):\n                raise return_value\n            return return_value\n            yield\n        mock.side_effect = coro\n\n    def test_ctor(self):\n        with self.assertRaises(AssertionError):\n            aiohttp.ProxyConnector('https://localhost:8118', loop=self.loop)\n\n    def test_ctor2(self):\n        connector = aiohttp.ProxyConnector('http://localhost:8118',\n                                           loop=self.loop)\n\n        self.assertEqual('http://localhost:8118', connector.proxy)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n\n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n\n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=None,\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\n\n    def test_proxy_auth(self):\n        with self.assertRaisesRegex(AssertionError,\n                                    \"must be None or BasicAuth\"):\n            aiohttp.ProxyConnector('http://proxy.example.com',\n                                   proxy_auth=('user', 'pass'),\n                                   loop=unittest.mock.Mock())\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_proxy_override_auth(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n\n        loop_mock = unittest.mock.Mock()\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com',\n            proxy_auth=aiohttp.BasicAuth(None, None),\n            loop=loop_mock)\n\n        def check_proxy_req(*args, **kw):\n            proxy_req = ClientRequest(*args, **kw)\n            self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n            return proxy_req\n\n        ClientRequestMock.side_effect = check_proxy_req\n        self.loop.run_until_complete(connector._create_connection(req))\n\n    def test_proxy_connection_error(self):\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=self.loop)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('dont take it serious'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        expected_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, '/')\n        self.assertEqual(dict(req.headers), expected_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_auth=aiohttp.BasicAuth('user', 'pass'))\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth('user', 'pass'),\n            loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n\n        ClientRequestMock.assert_called_with(\n            'GET', 'http://user:pass@proxy.example.com',\n            auth=None, loop=unittest.mock.ANY, headers=unittest.mock.ANY)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth__not_modifying_request(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        proxy_req_headers = dict(proxy_req.headers)\n\n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, OSError('nothing personal'))\n\n        req = ClientRequest('GET', 'http://www.python.org')\n        req_headers = dict(req.headers)\n        with self.assertRaises(aiohttp.ProxyConnectionError):\n            self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.headers, req_headers)\n        self.assertEqual(req.path, '/')\n        self.assertEqual(proxy_req.headers, proxy_req_headers)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        self.loop.run_until_complete(connector._create_connection(req))\n\n        self.assertEqual(proxy_req.method, 'CONNECT')\n        self.assertEqual(proxy_req.path, 'www.python.org:443')\n        tr.pause_reading.assert_called_once_with()\n        tr.get_extra_info.assert_called_once_with('socket', default=None)\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_runtime_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, unittest.mock.Mock(status=200))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                RuntimeError, \"Transport does not expose socket instance\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_http_proxy_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(\n            start_mock, unittest.mock.Mock(status=400, reason='bad request'))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(\n                aiohttp.HttpProxyError, \"(400, 'bad request')\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_https_connect_resp_start_error(self, ClientRequestMock):\n        loop_mock = unittest.mock.Mock()\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  loop=loop_mock)\n        ClientRequestMock.return_value = proxy_req\n\n        proxy_resp = ClientResponse('get', 'http://proxy.example.com')\n        proxy_req.send = send_mock = unittest.mock.Mock()\n        send_mock.return_value = proxy_resp\n        proxy_resp.start = start_mock = unittest.mock.Mock()\n        self._fake_coroutine(start_mock, OSError(\"error message\"))\n\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock)\n\n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        tr.get_extra_info.return_value = None\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n\n        req = ClientRequest('GET', 'https://www.python.org')\n        with self.assertRaisesRegex(OSError, \"error message\"):\n            self.loop.run_until_complete(connector._create_connection(req))\n"
    ],
    "test_file_names": [
        "test_1.py"
    ],
    "setup_res_code": 0,
    "setup_res_stdout": "Transforming aiohttp/worker.py\nTransforming aiohttp/server.py\nTransforming aiohttp/client.py\n",
    "setup_res_stderr": "Using CPython 3.9.21\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nmake: *** No rule to make target '.develop'.  Stop.\nResolved 26 packages in 20ms\nInstalled 26 packages in 23ms\n + async-generator==1.10\n + async-timeout==5.0.1\n + brotlipy==0.7.0\n + cffi==1.17.1\n + chardet==5.2.0\n + coverage==7.6.10\n + cryptography==44.0.0\n + cython==3.0.11\n + exceptiongroup==1.2.2\n + gunicorn==23.0.0\n + idna==3.10\n + iniconfig==2.0.0\n + multdict==0.0.5\n + multidict==6.1.0\n + packaging==24.2\n + pluggy==1.5.0\n + propcache==0.2.1\n + pycparser==2.22\n + pytest==8.3.4\n + pytest-asyncio==0.25.0\n + pytest-cov==6.0.0\n + pytest-mock==3.14.0\n + tomli==2.2.1\n + trustme==1.2.1\n + typing-extensions==4.12.2\n + yarl==1.18.3\n",
    "new_commit_res_code": 1,
    "new_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.9.21, pytest-8.3.4, pluggy-1.5.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_750a09537324940f2b29cf62e023a94b9a1a8709\nplugins: asyncio-0.25.0, mock-3.14.0, cov-6.0.0\nasyncio: mode=strict, asyncio_default_fixture_loop_scope=None\ncollected 32 items\n\nr2e_tests/test_1.py .................FF.............                     [100%]\n\n=================================== FAILURES ===================================\n_________________ HttpClientConnectorTests.test_tcp_connector __________________\n\nself = <r2e_tests.test_1.HttpClientConnectorTests testMethod=test_tcp_connector>\n\n    def test_tcp_connector(self):\n        with test_utils.run_server(self.loop, router=Functional) as httpd:\n>           r = self.loop.run_until_complete(\n                client.request(\n                    'get', httpd.url('method', 'get'),\n                    connector=aiohttp.TCPConnector(loop=self.loop),\n                    loop=self.loop))\n\nr2e_tests/test_1.py:261: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n../../../../.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/asyncio/base_events.py:647: in run_until_complete\n    return future.result()\naiohttp/client.py:105: in request\n    conn = yield from connector.connect(req)\naiohttp/connector.py:138: in connect\n    transport, proto = yield from self._create_connection(req)\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n\nself = <aiohttp.connector.TCPConnector object at 0x75dcd5865550>\nreq = <aiohttp.client.ClientRequest object at 0x75dcd5865eb0>, kwargs = {}\nsslcontext = False, hosts = []\nhinfo = {'family': <AddressFamily.AF_INET: 2>, 'flags': 0, 'host': '127.0.0.1', 'hostname': '127.0.0.1', ...}\n\n    def _create_connection(self, req, **kwargs):\n        \"\"\"Create connection. Has same keyword arguments\n        as BaseEventLoop.create_connection\n        \"\"\"\n        sslcontext = req.ssl\n        if req.ssl and not self._verify_ssl:\n            sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)\n            sslcontext.options |= ssl.OP_NO_SSLv2\n            sslcontext.set_default_verify_paths()\n    \n        hosts = yield from self._resolve_host(req.host, req.port)\n    \n        while hosts:\n            hinfo = hosts.pop()\n            try:\n>               return (yield from self._loop.create_connection(\n                    self._factory, hinfo['host'], hinfo['port'],\n                    ssl=sslcontext, family=hinfo['family'],\n                    proto=hinfo['proto'], flags=hinfo['flags'],\n                    server_hostname=hinfo['hostname'] if sslcontext else None,\n                    **kwargs))\nE                   TypeError: cannot 'yield from' a coroutine object in a non-coroutine generator\n\naiohttp/connector.py:263: TypeError\n_________________ HttpClientConnectorTests.test_unix_connector _________________\n\nself = <r2e_tests.test_1.HttpClientConnectorTests testMethod=test_unix_connector>\n\n    @unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'requires unix')\n    def test_unix_connector(self):\n        path = '/tmp/aiohttp_unix.sock'\n    \n        connector = aiohttp.UnixConnector(path, loop=self.loop)\n        self.assertEqual(path, connector.path)\n    \n        with test_utils.run_server(\n                self.loop, listen_addr=path, router=Functional) as httpd:\n>           r = self.loop.run_until_complete(\n                client.request(\n                    'get', httpd.url('method', 'get'),\n                    connector=connector,\n                    loop=self.loop))\n\nr2e_tests/test_1.py:280: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n../../../../.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/asyncio/base_events.py:647: in run_until_complete\n    return future.result()\naiohttp/client.py:107: in request\n    resp = req.send(conn.writer, conn.reader)\naiohttp/client.py:531: in send\n    request.send_headers()\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n\nself = <aiohttp.protocol.Request object at 0x75dcd58b7040>\n\n    def send_headers(self):\n        \"\"\"Writes headers to a stream. Constructs payload writer.\"\"\"\n        # Chunked response is only for HTTP/1.1 clients or newer\n        # and there is no Content-Length header is set.\n        # Do not use chunked responses when the response is guaranteed to\n        # not have a response body (304, 204).\n        assert not self.headers_sent, 'headers have been sent already'\n        self.headers_sent = True\n    \n        if (self.chunked is True) or (\n                self.length is None and\n                self.version >= (1, 1) and\n                self.status not in (304, 204)):\n            self.chunked = True\n            self.writer = self._write_chunked_payload()\n    \n        elif self.length is not None:\n            self.writer = self._write_length_payload(self.length)\n    \n        else:\n            self.writer = self._write_eof_payload()\n    \n        next(self.writer)\n    \n        self._add_default_headers()\n    \n        # status + headers\n        hdrs = ''.join(itertools.chain(\n            (self.status_line,),\n            *((k, ': ', v, '\\r\\n')\n              for k, v in ((k, value)\n                           for k, value in self.headers.items(getall=True)))))\n        hdrs = hdrs.encode('utf-8') + b'\\r\\n'\n    \n        self.output_length += len(hdrs)\n>       self.transport.write(hdrs)\nE       AttributeError: 'NoneType' object has no attribute 'write'\n\naiohttp/protocol.py:643: AttributeError\n------------------------------ Captured log call -------------------------------\nERROR    asyncio:base_events.py:1753 Exception in callback StreamProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)\nhandle: <Handle StreamProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)>\nTraceback (most recent call last):\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/asyncio/events.py\", line 80, in _run\n    self._context.run(self._callback, *self._args)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_750a09537324940f2b29cf62e023a94b9a1a8709/aiohttp/parsers.py\", line 252, in connection_made\n    self.writer = asyncio.streams.StreamWriter(\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/asyncio/streams.py\", line 324, in __init__\n    assert reader is None or isinstance(reader, StreamReader)\nAssertionError\nERROR    asyncio:base_events.py:1753 Exception in callback run_server.<locals>.TestHttpServer.connection_made(<_SelectorSoc...e, bufsize=0>>)\nhandle: <Handle run_server.<locals>.TestHttpServer.connection_made(<_SelectorSoc...e, bufsize=0>>)>\nTraceback (most recent call last):\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/asyncio/events.py\", line 80, in _run\n    self._context.run(self._callback, *self._args)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_750a09537324940f2b29cf62e023a94b9a1a8709/aiohttp/test_utils.py\", line 68, in connection_made\n    super().connection_made(transport)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_750a09537324940f2b29cf62e023a94b9a1a8709/aiohttp/server.py\", line 86, in connection_made\n    super().connection_made(transport)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_750a09537324940f2b29cf62e023a94b9a1a8709/aiohttp/parsers.py\", line 252, in connection_made\n    self.writer = asyncio.streams.StreamWriter(\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/asyncio/streams.py\", line 324, in __init__\n    assert reader is None or isinstance(reader, StreamReader)\nAssertionError\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::HttpConnectionTests::test_close\nPASSED r2e_tests/test_1.py::HttpConnectionTests::test_del\nPASSED r2e_tests/test_1.py::HttpConnectionTests::test_release\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_cleanup\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_close\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_connect\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_create_conn\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_ctor_loop\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_del\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_get\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_get_expired\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_release\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_release_close\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_release_not_opened\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_release_not_started\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_start_cleanup_task\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_tcp_connector_ctor\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_auth\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_auth__not_modifying_request\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_auth_from_url\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_connect\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_ctor\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_ctor2\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_https_connect\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_https_connect_http_proxy_error\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_https_connect_resp_start_error\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_https_connect_runtime_error\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_proxy_auth\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_proxy_connection_error\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_proxy_override_auth\nFAILED r2e_tests/test_1.py::HttpClientConnectorTests::test_tcp_connector - Ty...\nFAILED r2e_tests/test_1.py::HttpClientConnectorTests::test_unix_connector - A...\n========================= 2 failed, 30 passed in 0.64s =========================\n",
    "new_commit_res_stderr": "/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_750a09537324940f2b29cf62e023a94b9a1a8709/.venv/lib/python3.9/site-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option \"asyncio_default_fixture_loop_scope\" is unset.\nThe event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: \"function\", \"class\", \"module\", \"package\", \"session\"\n\n  warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))\n",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.9.21, pytest-8.3.4, pluggy-1.5.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_750a09537324940f2b29cf62e023a94b9a1a8709\nplugins: asyncio-0.25.0, mock-3.14.0, cov-6.0.0\nasyncio: mode=strict, asyncio_default_fixture_loop_scope=None\ncollected 32 items\n\nr2e_tests/test_1.py .................FFF.FF......F..                     [100%]\n\n=================================== FAILURES ===================================\n_________________ HttpClientConnectorTests.test_tcp_connector __________________\n\nself = <r2e_tests.test_1.HttpClientConnectorTests testMethod=test_tcp_connector>\n\n    def test_tcp_connector(self):\n        with test_utils.run_server(self.loop, router=Functional) as httpd:\n>           r = self.loop.run_until_complete(\n                client.request(\n                    'get', httpd.url('method', 'get'),\n                    connector=aiohttp.TCPConnector(loop=self.loop),\n                    loop=self.loop))\n\nr2e_tests/test_1.py:261: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n../../../../.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/asyncio/base_events.py:647: in run_until_complete\n    return future.result()\naiohttp/client.py:105: in request\n    conn = yield from connector.connect(req)\naiohttp/connector.py:138: in connect\n    transport, proto = yield from self._create_connection(req)\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n\nself = <aiohttp.connector.TCPConnector object at 0x7b193c37ecd0>\nreq = <aiohttp.client.ClientRequest object at 0x7b193c37eca0>, kwargs = {}\nsslcontext = False, hosts = []\nhinfo = {'family': <AddressFamily.AF_INET: 2>, 'flags': 0, 'host': '127.0.0.1', 'hostname': '127.0.0.1', ...}\n\n    def _create_connection(self, req, **kwargs):\n        \"\"\"Create connection. Has same keyword arguments\n        as BaseEventLoop.create_connection\n        \"\"\"\n        sslcontext = req.ssl\n        if req.ssl and not self._verify_ssl:\n            sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)\n            sslcontext.options |= ssl.OP_NO_SSLv2\n            sslcontext.set_default_verify_paths()\n    \n        hosts = yield from self._resolve_host(req.host, req.port)\n    \n        while hosts:\n            hinfo = hosts.pop()\n            try:\n>               return (yield from self._loop.create_connection(\n                    self._factory, hinfo['host'], hinfo['port'],\n                    ssl=sslcontext, family=hinfo['family'],\n                    proto=hinfo['proto'], flags=hinfo['flags'],\n                    server_hostname=hinfo['hostname'] if sslcontext else None,\n                    **kwargs))\nE                   TypeError: cannot 'yield from' a coroutine object in a non-coroutine generator\n\naiohttp/connector.py:263: TypeError\n_________________ HttpClientConnectorTests.test_unix_connector _________________\n\nself = <r2e_tests.test_1.HttpClientConnectorTests testMethod=test_unix_connector>\n\n    @unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'requires unix')\n    def test_unix_connector(self):\n        path = '/tmp/aiohttp_unix.sock'\n    \n        connector = aiohttp.UnixConnector(path, loop=self.loop)\n        self.assertEqual(path, connector.path)\n    \n        with test_utils.run_server(\n                self.loop, listen_addr=path, router=Functional) as httpd:\n>           r = self.loop.run_until_complete(\n                client.request(\n                    'get', httpd.url('method', 'get'),\n                    connector=connector,\n                    loop=self.loop))\n\nr2e_tests/test_1.py:280: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n../../../../.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/asyncio/base_events.py:647: in run_until_complete\n    return future.result()\naiohttp/client.py:107: in request\n    resp = req.send(conn.writer, conn.reader)\naiohttp/client.py:531: in send\n    request.send_headers()\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n\nself = <aiohttp.protocol.Request object at 0x7b193b9105b0>\n\n    def send_headers(self):\n        \"\"\"Writes headers to a stream. Constructs payload writer.\"\"\"\n        # Chunked response is only for HTTP/1.1 clients or newer\n        # and there is no Content-Length header is set.\n        # Do not use chunked responses when the response is guaranteed to\n        # not have a response body (304, 204).\n        assert not self.headers_sent, 'headers have been sent already'\n        self.headers_sent = True\n    \n        if (self.chunked is True) or (\n                self.length is None and\n                self.version >= (1, 1) and\n                self.status not in (304, 204)):\n            self.chunked = True\n            self.writer = self._write_chunked_payload()\n    \n        elif self.length is not None:\n            self.writer = self._write_length_payload(self.length)\n    \n        else:\n            self.writer = self._write_eof_payload()\n    \n        next(self.writer)\n    \n        self._add_default_headers()\n    \n        # status + headers\n        hdrs = ''.join(itertools.chain(\n            (self.status_line,),\n            *((k, ': ', v, '\\r\\n')\n              for k, v in ((k, value)\n                           for k, value in self.headers.items(getall=True)))))\n        hdrs = hdrs.encode('utf-8') + b'\\r\\n'\n    \n        self.output_length += len(hdrs)\n>       self.transport.write(hdrs)\nE       AttributeError: 'NoneType' object has no attribute 'write'\n\naiohttp/protocol.py:643: AttributeError\n------------------------------ Captured log call -------------------------------\nERROR    asyncio:base_events.py:1753 Exception in callback StreamProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)\nhandle: <Handle StreamProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)>\nTraceback (most recent call last):\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/asyncio/events.py\", line 80, in _run\n    self._context.run(self._callback, *self._args)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_750a09537324940f2b29cf62e023a94b9a1a8709/aiohttp/parsers.py\", line 252, in connection_made\n    self.writer = asyncio.streams.StreamWriter(\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/asyncio/streams.py\", line 324, in __init__\n    assert reader is None or isinstance(reader, StreamReader)\nAssertionError\nERROR    asyncio:base_events.py:1753 Exception in callback run_server.<locals>.TestHttpServer.connection_made(<_SelectorSoc...e, bufsize=0>>)\nhandle: <Handle run_server.<locals>.TestHttpServer.connection_made(<_SelectorSoc...e, bufsize=0>>)>\nTraceback (most recent call last):\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/asyncio/events.py\", line 80, in _run\n    self._context.run(self._callback, *self._args)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_750a09537324940f2b29cf62e023a94b9a1a8709/aiohttp/test_utils.py\", line 68, in connection_made\n    super().connection_made(transport)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_750a09537324940f2b29cf62e023a94b9a1a8709/aiohttp/server.py\", line 86, in connection_made\n    super().connection_made(transport)\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_750a09537324940f2b29cf62e023a94b9a1a8709/aiohttp/parsers.py\", line 252, in connection_made\n    self.writer = asyncio.streams.StreamWriter(\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/asyncio/streams.py\", line 324, in __init__\n    assert reader is None or isinstance(reader, StreamReader)\nAssertionError\n________________________ ProxyConnectorTests.test_auth _________________________\n\nself = <MagicMock name='ClientRequest' id='135348303754864'>\nargs = ('GET', 'http://proxy.example.com')\nkwargs = {'auth': BasicAuth(login='user', password='pass'), 'headers': <ANY>, 'loop': <ANY>}\nexpected = call('GET', 'http://proxy.example.com', auth=BasicAuth(login='user', password='pass'), loop=<ANY>, headers=<ANY>)\nactual = call('GET', 'http://proxy.example.com', headers={'Host': 'www.python.org'}, auth=BasicAuth(login=None, password=None), loop=<Mock id='135348313794832'>)\n_error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7b193c283940>\ncause = None\n\n    def assert_called_with(self, /, *args, **kwargs):\n        \"\"\"assert that the last call was made with the specified arguments.\n    \n        Raises an AssertionError if the args and keyword args passed in are\n        different to the last call to the mock.\"\"\"\n        if self.call_args is None:\n            expected = self._format_mock_call_signature(args, kwargs)\n            actual = 'not called.'\n            error_message = ('expected call not found.\\nExpected: %s\\nActual: %s'\n                    % (expected, actual))\n            raise AssertionError(error_message)\n    \n        def _error_message():\n            msg = self._format_mock_failure_message(args, kwargs)\n            return msg\n        expected = self._call_matcher(_Call((args, kwargs), two=True))\n        actual = self._call_matcher(self.call_args)\n        if actual != expected:\n            cause = expected if isinstance(expected, Exception) else None\n>           raise AssertionError(_error_message()) from cause\nE           AssertionError: expected call not found.\nE           Expected: ClientRequest('GET', 'http://proxy.example.com', auth=BasicAuth(login='user', password='pass'), loop=<ANY>, headers=<ANY>)\nE           Actual: ClientRequest('GET', 'http://proxy.example.com', headers={'Host': 'www.python.org'}, auth=BasicAuth(login=None, password=None), loop=<Mock id='135348313794832'>)\n\n../../../../.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/mock.py:907: AssertionError\n\nDuring handling of the above exception, another exception occurred:\n\nself = <r2e_tests.test_1.ProxyConnectorTests testMethod=test_auth>\nClientRequestMock = <MagicMock name='ClientRequest' id='135348303754864'>\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://proxy.example.com',\n                                  auth=aiohttp.BasicAuth('user', 'pass'))\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n    \n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://proxy.example.com', loop=loop_mock,\n            proxy_auth=aiohttp.BasicAuth('user', 'pass'))\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n    \n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n    \n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n    \n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n    \n>       ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=aiohttp.BasicAuth('user', 'pass'),\n            loop=unittest.mock.ANY, headers=unittest.mock.ANY)\nE       AssertionError: expected call not found.\nE       Expected: ClientRequest('GET', 'http://proxy.example.com', auth=BasicAuth(login='user', password='pass'), loop=<ANY>, headers=<ANY>)\nE       Actual: ClientRequest('GET', 'http://proxy.example.com', headers={'Host': 'www.python.org'}, auth=BasicAuth(login=None, password=None), loop=<Mock id='135348313794832'>)\nE       \nE       pytest introspection follows:\nE       \nE       Kwargs:\nE       assert {'auth': Basi...48313794832'>} == {'auth': Basi...'loop': <ANY>}\nE         \nE         Omitting 2 identical items, use -vv to show\nE         Differing items:\nE         {'auth': BasicAuth(login=None, password=None)} != {'auth': BasicAuth(login='user', password='pass')}\nE         Use -v to get more diff\n\nr2e_tests/test_1.py:423: AssertionError\n____________________ ProxyConnectorTests.test_auth_from_url ____________________\n\nself = <MagicMock name='ClientRequest' id='135348304128224'>\nargs = ('GET', 'http://user:pass@proxy.example.com')\nkwargs = {'auth': None, 'headers': <ANY>, 'loop': <ANY>}\nexpected = call('GET', 'http://user:pass@proxy.example.com', auth=None, loop=<ANY>, headers=<ANY>)\nactual = call('GET', 'http://user:pass@proxy.example.com', headers={'Host': 'www.python.org'}, auth=BasicAuth(login=None, password=None), loop=<Mock id='135348314648384'>)\n_error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7b193c406d30>\ncause = None\n\n    def assert_called_with(self, /, *args, **kwargs):\n        \"\"\"assert that the last call was made with the specified arguments.\n    \n        Raises an AssertionError if the args and keyword args passed in are\n        different to the last call to the mock.\"\"\"\n        if self.call_args is None:\n            expected = self._format_mock_call_signature(args, kwargs)\n            actual = 'not called.'\n            error_message = ('expected call not found.\\nExpected: %s\\nActual: %s'\n                    % (expected, actual))\n            raise AssertionError(error_message)\n    \n        def _error_message():\n            msg = self._format_mock_failure_message(args, kwargs)\n            return msg\n        expected = self._call_matcher(_Call((args, kwargs), two=True))\n        actual = self._call_matcher(self.call_args)\n        if actual != expected:\n            cause = expected if isinstance(expected, Exception) else None\n>           raise AssertionError(_error_message()) from cause\nE           AssertionError: expected call not found.\nE           Expected: ClientRequest('GET', 'http://user:pass@proxy.example.com', auth=None, loop=<ANY>, headers=<ANY>)\nE           Actual: ClientRequest('GET', 'http://user:pass@proxy.example.com', headers={'Host': 'www.python.org'}, auth=BasicAuth(login=None, password=None), loop=<Mock id='135348314648384'>)\n\n../../../../.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/mock.py:907: AssertionError\n\nDuring handling of the above exception, another exception occurred:\n\nself = <r2e_tests.test_1.ProxyConnectorTests testMethod=test_auth_from_url>\nClientRequestMock = <MagicMock name='ClientRequest' id='135348304128224'>\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_auth_from_url(self, ClientRequestMock):\n        proxy_req = ClientRequest('GET', 'http://user:pass@proxy.example.com')\n        ClientRequestMock.return_value = proxy_req\n        self.assertIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n    \n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector(\n            'http://user:pass@proxy.example.com', loop=loop_mock)\n        connector._resolve_host = resolve_mock = unittest.mock.Mock()\n        self._fake_coroutine(resolve_mock, [unittest.mock.MagicMock()])\n    \n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n    \n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', req.headers)\n        self.loop.run_until_complete(connector.connect(req))\n    \n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertNotIn('AUTHORIZATION', req.headers)\n        self.assertIn('PROXY-AUTHORIZATION', req.headers)\n        self.assertNotIn('AUTHORIZATION', proxy_req.headers)\n        self.assertNotIn('PROXY-AUTHORIZATION', proxy_req.headers)\n    \n>       ClientRequestMock.assert_called_with(\n            'GET', 'http://user:pass@proxy.example.com',\n            auth=None, loop=unittest.mock.ANY, headers=unittest.mock.ANY)\nE       AssertionError: expected call not found.\nE       Expected: ClientRequest('GET', 'http://user:pass@proxy.example.com', auth=None, loop=<ANY>, headers=<ANY>)\nE       Actual: ClientRequest('GET', 'http://user:pass@proxy.example.com', headers={'Host': 'www.python.org'}, auth=BasicAuth(login=None, password=None), loop=<Mock id='135348314648384'>)\nE       \nE       pytest introspection follows:\nE       \nE       Kwargs:\nE       assert {'auth': Basi...48314648384'>} == {'auth': None...'loop': <ANY>}\nE         \nE         Omitting 2 identical items, use -vv to show\nE         Differing items:\nE         {'auth': BasicAuth(login=None, password=None)} != {'auth': None}\nE         Use -v to get more diff\n\nr2e_tests/test_1.py:455: AssertionError\n_______________________ ProxyConnectorTests.test_connect _______________________\n\nself = <MagicMock name='ClientRequest' id='135348313533408'>\nargs = ('GET', 'http://proxy.example.com')\nkwargs = {'auth': None, 'headers': {'Host': 'www.python.org'}, 'loop': <Mock id='135348304066784'>}\nexpected = call('GET', 'http://proxy.example.com', auth=None, headers={'Host': 'www.python.org'}, loop=<Mock id='135348304066784'>)\nactual = call('GET', 'http://proxy.example.com', headers={'Host': 'www.python.org'}, auth=BasicAuth(login=None, password=None), loop=<Mock id='135348304066784'>)\n_error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7b193c2ea9d0>\ncause = None\n\n    def assert_called_with(self, /, *args, **kwargs):\n        \"\"\"assert that the last call was made with the specified arguments.\n    \n        Raises an AssertionError if the args and keyword args passed in are\n        different to the last call to the mock.\"\"\"\n        if self.call_args is None:\n            expected = self._format_mock_call_signature(args, kwargs)\n            actual = 'not called.'\n            error_message = ('expected call not found.\\nExpected: %s\\nActual: %s'\n                    % (expected, actual))\n            raise AssertionError(error_message)\n    \n        def _error_message():\n            msg = self._format_mock_failure_message(args, kwargs)\n            return msg\n        expected = self._call_matcher(_Call((args, kwargs), two=True))\n        actual = self._call_matcher(self.call_args)\n        if actual != expected:\n            cause = expected if isinstance(expected, Exception) else None\n>           raise AssertionError(_error_message()) from cause\nE           AssertionError: expected call not found.\nE           Expected: ClientRequest('GET', 'http://proxy.example.com', auth=None, headers={'Host': 'www.python.org'}, loop=<Mock id='135348304066784'>)\nE           Actual: ClientRequest('GET', 'http://proxy.example.com', headers={'Host': 'www.python.org'}, auth=BasicAuth(login=None, password=None), loop=<Mock id='135348304066784'>)\n\n../../../../.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/mock.py:907: AssertionError\n\nDuring handling of the above exception, another exception occurred:\n\nself = <r2e_tests.test_1.ProxyConnectorTests testMethod=test_connect>\nClientRequestMock = <MagicMock name='ClientRequest' id='135348313533408'>\n\n    @unittest.mock.patch('aiohttp.connector.ClientRequest')\n    def test_connect(self, ClientRequestMock):\n        req = ClientRequest('GET', 'http://www.python.org')\n        self.assertEqual(req.path, '/')\n    \n        loop_mock = unittest.mock.Mock()\n        connector = aiohttp.ProxyConnector('http://proxy.example.com',\n                                           loop=loop_mock)\n        self.assertIs(loop_mock, connector._loop)\n    \n        resolve_host = unittest.mock.Mock()\n        self._fake_coroutine(resolve_host, [unittest.mock.MagicMock()])\n        connector._resolve_host = resolve_host\n    \n        tr, proto = unittest.mock.Mock(), unittest.mock.Mock()\n        self._fake_coroutine(loop_mock.create_connection, (tr, proto))\n        conn = self.loop.run_until_complete(connector.connect(req))\n        self.assertEqual(req.path, 'http://www.python.org/')\n        self.assertIs(conn._transport, tr)\n        self.assertIs(conn._protocol, proto)\n    \n        # resolve_host.assert_called_once_with('proxy.example.com', 80)\n        self.assertEqual(tr.mock_calls, [])\n    \n>       ClientRequestMock.assert_called_with(\n            'GET', 'http://proxy.example.com',\n            auth=None,\n            headers={'Host': 'www.python.org'},\n            loop=loop_mock)\nE       AssertionError: expected call not found.\nE       Expected: ClientRequest('GET', 'http://proxy.example.com', auth=None, headers={'Host': 'www.python.org'}, loop=<Mock id='135348304066784'>)\nE       Actual: ClientRequest('GET', 'http://proxy.example.com', headers={'Host': 'www.python.org'}, auth=BasicAuth(login=None, password=None), loop=<Mock id='135348304066784'>)\nE       \nE       pytest introspection follows:\nE       \nE       Kwargs:\nE       assert {'auth': Basi...48304066784'>} == {'auth': None...48304066784'>}\nE         \nE         Omitting 2 identical items, use -vv to show\nE         Differing items:\nE         {'auth': BasicAuth(login=None, password=None)} != {'auth': None}\nE         Use -v to get more diff\n\nr2e_tests/test_1.py:347: AssertionError\n_____________________ ProxyConnectorTests.test_proxy_auth ______________________\n\nself = <r2e_tests.test_1.ProxyConnectorTests testMethod=test_proxy_auth>\n\n    def test_proxy_auth(self):\n        with self.assertRaisesRegex(AssertionError,\n                                    \"must be None or BasicAuth\"):\n>           aiohttp.ProxyConnector('http://proxy.example.com',\n                                   proxy_auth=('user', 'pass'),\n                                   loop=unittest.mock.Mock())\nE           AssertionError: AssertionError not raised\n\nr2e_tests/test_1.py:356: AssertionError\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::HttpConnectionTests::test_close\nPASSED r2e_tests/test_1.py::HttpConnectionTests::test_del\nPASSED r2e_tests/test_1.py::HttpConnectionTests::test_release\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_cleanup\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_close\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_connect\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_create_conn\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_ctor_loop\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_del\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_get\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_get_expired\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_release\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_release_close\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_release_not_opened\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_release_not_started\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_start_cleanup_task\nPASSED r2e_tests/test_1.py::BaseConnectorTests::test_tcp_connector_ctor\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_auth__not_modifying_request\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_ctor\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_ctor2\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_https_connect\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_https_connect_http_proxy_error\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_https_connect_resp_start_error\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_https_connect_runtime_error\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_proxy_connection_error\nPASSED r2e_tests/test_1.py::ProxyConnectorTests::test_proxy_override_auth\nFAILED r2e_tests/test_1.py::HttpClientConnectorTests::test_tcp_connector - Ty...\nFAILED r2e_tests/test_1.py::HttpClientConnectorTests::test_unix_connector - A...\nFAILED r2e_tests/test_1.py::ProxyConnectorTests::test_auth - AssertionError: ...\nFAILED r2e_tests/test_1.py::ProxyConnectorTests::test_auth_from_url - Asserti...\nFAILED r2e_tests/test_1.py::ProxyConnectorTests::test_connect - AssertionErro...\nFAILED r2e_tests/test_1.py::ProxyConnectorTests::test_proxy_auth - AssertionE...\n========================= 6 failed, 26 passed in 0.63s =========================\n",
    "old_commit_res_stderr": "/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_750a09537324940f2b29cf62e023a94b9a1a8709/.venv/lib/python3.9/site-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option \"asyncio_default_fixture_loop_scope\" is unset.\nThe event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: \"function\", \"class\", \"module\", \"package\", \"session\"\n\n  warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))\n"
}
aiohttp/connector.py tests/test_connector.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** ProxyConnector Sets Incorrect Authentication Parameters in ClientRequest

**Description:**
After updating the `ProxyConnector` to use the `proxy_auth` parameter instead of separate `proxy_login` and `proxy_passwd`, certain authentication scenarios are not handled correctly. When initializing `ProxyConnector` with `proxy_auth`, the `ClientRequest` is inadvertently receiving `BasicAuth` with `login=None` and `password=None` instead of the intended credentials.

**Example Buggy Code:**
```python
connector = aiohttp.ProxyConnector(
    'http://proxy.example.com',
    proxy_auth=aiohttp.BasicAuth('user', 'pass'),
    loop=loop_mock
)
req = ClientRequest('GET', 'http://www.python.org')
await connector.connect(req)
```

In this scenario, the `ClientRequest` should be initialized with `auth=BasicAuth('user', 'pass')`. However, it is instead receiving `auth=BasicAuth(login=None, password=None)`.

**Expected Behavior:**
The `ClientRequest` should correctly receive the provided `BasicAuth` credentials (`user` and `pass`) when `proxy_auth` is specified. If no `proxy_auth` is provided, the `auth` parameter should be set to `None`.

**Actual Behavior:**
The `ClientRequest` receives `BasicAuth` with `login=None` and `password=None` even when valid credentials are provided through `proxy_auth`. This leads to failed authentication attempts with the proxy server.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### aiohttp/connector.py
__all__ = ['BaseConnector', 'TCPConnector', 'UnixConnector',
           'SocketConnector', 'UnixSocketConnector', 'ProxyConnector']

import asyncio
import aiohttp
import functools
import http.cookies
import time
import ssl
import socket
import weakref

from .errors import HttpProxyError
from .errors import ProxyConnectionError
from .client import ClientRequest


class Connection(object):

    def __init__(self, connector, key, request, transport, protocol):
        self._key = key
        self._connector = connector
        self._request = request
        self._transport = transport
        self._protocol = protocol
        self.reader = protocol.reader
        self.writer = protocol.writer
        self._wr = weakref.ref(self, lambda wr, tr=self._transport: tr.close())

    def close(self):
        if self._transport is not None:
            self._transport.close()
            self._transport = None
            self._wr = None

    def release(self):
        if self._transport:
            self._connector._release(
                self._key, self._request, self._transport, self._protocol)
            self._transport = None
            self._wr = None


class BaseConnector(object):

    def __init__(self, *, conn_timeout=None, keepalive_timeout=30,
                 share_cookies=False, force_close=False, loop=None, **kwargs):
        self._conns = {}
        self._conn_timeout = conn_timeout
        self._keepalive_timeout = keepalive_timeout
        self._share_cookies = share_cookies
        self._cleanup_handle = None
        self._force_close = force_close

        if loop is None:
            loop = asyncio.get_event_loop()
        self._loop = loop
        self._factory = functools.partial(aiohttp.StreamProtocol, loop=loop)

        self.cookies = http.cookies.SimpleCookie()
        self._wr = weakref.ref(
            self, lambda wr, f=self._do_close, conns=self._conns: f(conns))

    def _cleanup(self):
        """Cleanup unused transports."""
        if self._cleanup_handle:
            self._cleanup_handle.cancel()
            self._cleanup_handle = None

        now = time.time()

        connections = {}
        for key, conns in self._conns.items():
            alive = []
            for transport, proto, t0 in conns:
                if transport is not None:
                    if proto and not proto.is_connected():
                        transport = None
                    elif (now - t0) > self._keepalive_timeout:
                        transport.close()
                        transport = None

                if transport:
                    alive.append((transport, proto, t0))
            if alive:
                connections[key] = alive

        if connections:
            self._cleanup_handle = self._loop.call_later(
                self._keepalive_timeout, self._cleanup)

        self._conns = connections
        self._wr = weakref.ref(
            self, lambda wr, f=self._do_close, conns=self._conns: f(conns))

    def _start_cleanup_task(self):
        if self._cleanup_handle is None:
            self._cleanup_handle = self._loop.call_later(
                self._keepalive_timeout, self._cleanup)

    def close(self):
        """Close all opened transports."""
        self._do_close(self._conns)

    @staticmethod
    def _do_close(conns):
        for key, data in conns.items():
            for transport, proto, td in data:
                transport.close()

        conns.clear()

    def update_cookies(self, cookies):
        if isinstance(cookies, dict):
            cookies = cookies.items()

        for name, value in cookies:
            if isinstance(value, http.cookies.Morsel):
                # use dict method because SimpleCookie class modifies value
                dict.__setitem__(self.cookies, name, value)
            else:
                self.cookies[name] = value

    @asyncio.coroutine
    def connect(self, req):
        key = (req.host, req.port, req.ssl)

        if self._share_cookies:
            req.update_cookies(self.cookies.items())

        transport, proto = self._get(key)
        if transport is None:
            if self._conn_timeout:
                transport, proto = yield from asyncio.wait_for(
                    self._create_connection(req),
                    self._conn_timeout, loop=self._loop)
            else:
                transport, proto = yield from self._create_connection(req)

        return Connection(self, key, req, transport, proto)

    def _get(self, key):
        conns = self._conns.get(key)
        while conns:
            transport, proto, t0 = conns.pop()
            if transport is not None and proto.is_connected():
                if (time.time() - t0) > self._keepalive_timeout:
                    transport.close()
                    transport = None
                else:
                    return transport, proto

        return None, None

    def _release(self, key, req, transport, protocol):
        resp = req.response
        should_close = False

        if resp is not None:
            if resp.message is None:
                should_close = True
            else:
                should_close = resp.message.should_close
                if self._share_cookies and resp.cookies:
                    self.update_cookies(resp.cookies.items())

        if self._force_close:
            should_close = True

        reader = protocol.reader
        if should_close or (reader.output and not reader.output.at_eof()):
            transport.close()
        else:
            conns = self._conns.get(key)
            if conns is None:
                conns = self._conns[key] = []
            conns.append((transport, protocol, time.time()))
            reader.unset_parser()

            self._start_cleanup_task()

    def _create_connection(self, req, *args, **kwargs):
        raise NotImplementedError()


class TCPConnector(BaseConnector):

    def __init__(self, *args, verify_ssl=True,
                 resolve=False, family=socket.AF_INET, **kwargs):
        super().__init__(*args, **kwargs)

        self._verify_ssl = verify_ssl
        self._family = family
        self._resolve = resolve
        self._resolved_hosts = {}

    @property
    def verify_ssl(self):
        """Do check for ssl certifications?"""
        return self._verify_ssl

    @property
    def family(self):
        """Socket family like AF_INET"""
        return self._family

    @property
    def resolve(self):
        """Do DNS lookup for host name?"""
        return self._resolve

    @property
    def resolved_hosts(self):
        """The dict of (host, port) -> (ipaddr, port) pairs"""
        return dict(self._resolved_hosts)

    def clear_resolved_hosts(self, host=None, port=None):
        if host is not None and port is not None:
            key = (host, port)
            if key in self._resolved_hosts:
                del self._resolved_hosts[key]
        else:
            self._resolved_hosts.clear()

    @asyncio.coroutine
    def _resolve_host(self, host, port):
        if self._resolve:
            key = (host, port)

            if key not in self._resolved_hosts:
                infos = yield from self._loop.getaddrinfo(
                    host, port, type=socket.SOCK_STREAM, family=self._family)

                hosts = []
                for family, _, proto, _, address in infos:
                    hosts.append(
                        {'hostname': host,
                         'host': address[0], 'port': address[1],
                         'family': family, 'proto': proto,
                         'flags': socket.AI_NUMERICHOST})
                self._resolved_hosts[key] = hosts

            return list(self._resolved_hosts[key])
        else:
            return [{'hostname': host, 'host': host, 'port': port,
                     'family': self._family, 'proto': 0, 'flags': 0}]

    def _create_connection(self, req, **kwargs):
        """Create connection. Has same keyword arguments
        as BaseEventLoop.create_connection
        """
        sslcontext = req.ssl
        if req.ssl and not self._verify_ssl:
            sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
            sslcontext.options |= ssl.OP_NO_SSLv2
            sslcontext.set_default_verify_paths()

        hosts = yield from self._resolve_host(req.host, req.port)

        while hosts:
            hinfo = hosts.pop()
            try:
                return (yield from self._loop.create_connection(
                    self._factory, hinfo['host'], hinfo['port'],
                    ssl=sslcontext, family=hinfo['family'],
                    proto=hinfo['proto'], flags=hinfo['flags'],
                    server_hostname=hinfo['hostname'] if sslcontext else None,
                    **kwargs))
            except OSError:
                if not hosts:
                    raise


class ProxyConnector(TCPConnector):
    """Http Proxy connector."""

    def __init__(self, proxy, proxy_login=None, proxy_passwd=None,
                 *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._proxy = proxy
        self._basic_login = proxy_login
        self._basic_passwd = proxy_passwd
        assert proxy.startswith('http://'), (
            "Only http proxy supported", proxy)

    @property
    def proxy(self):
        return self._proxy

    @asyncio.coroutine
    def _create_connection(self, req, **kwargs):
        proxy_req = ClientRequest(
            'GET', self._proxy,
            headers={'Host': req.host},
            auth=aiohttp.BasicAuth(self._basic_login, self._basic_passwd),
            loop=self._loop)
        try:
            transport, proto = yield from super()._create_connection(proxy_req)
        except OSError as exc:
            raise ProxyConnectionError(*exc.args) from exc
        req.path = '{scheme}://{host}{path}'.format(scheme=req.scheme,
                                                    host=req.host,
                                                    path=req.path)
        if 'AUTHORIZATION' in proxy_req.headers:
            auth = proxy_req.headers['AUTHORIZATION']
            del proxy_req.headers['AUTHORIZATION']
            req.headers['PROXY-AUTHORIZATION'] = auth

        if req.ssl:
            # For HTTPS requests over HTTP proxy
            # we must notify proxy to tunnel connection
            # so we send CONNECT command:
            #   CONNECT www.python.org:443 HTTP/1.1
            #   Host: www.python.org
            #
            # next we must do TLS handshake and so on
            # to do this we must wrap raw socket into secure one
            # asyncio handles this perfectly
            proxy_req.method = 'CONNECT'
            proxy_req.path = '{}:{}'.format(req.host, req.port)
            key = (req.host, req.port, req.ssl)
            conn = Connection(self, key, proxy_req, transport, proto)
            proxy_resp = proxy_req.send(conn.writer, conn.reader)
            try:
                resp = yield from proxy_resp.start(conn, True)
            except:
                proxy_resp.close()
                conn.close()
                raise
            else:
                if resp.status != 200:
                    raise HttpProxyError(resp.status, resp.reason)
                rawsock = transport.get_extra_info('socket', default=None)
                if rawsock is None:
                    raise RuntimeError(
                        "Transport does not expose socket instance")
                transport.pause_reading()
                transport, proto = yield from self._loop.create_connection(
                    self._factory, ssl=True, sock=rawsock,
                    server_hostname=req.host, **kwargs)

        return transport, proto


class UnixConnector(BaseConnector):

    def __init__(self, path, *args, **kw):
        super().__init__(*args, **kw)

        self._path = path

    @property
    def path(self):
        """Path to unix socket"""
        return self._path

    @asyncio.coroutine
    def _create_connection(self, req, **kwargs):
        return (yield from self._loop.create_unix_connection(
            self._factory, self._path, **kwargs))


SocketConnector = TCPConnector
UnixSocketConnector = UnixConnector

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
[ISSUE]
**Title:** ProxyConnector Sets Incorrect Authentication Parameters in ClientRequest

**Description:**
After updating the `ProxyConnector` to use the `proxy_auth` parameter instead of separate `proxy_login` and `proxy_passwd`, certain authentication scenarios are not handled correctly. When initializing `ProxyConnector` with `proxy_auth`, the `ClientRequest` is inadvertently receiving `BasicAuth` with `login=None` and `password=None` instead of the intended credentials.

**Example Buggy Code:**
```python
connector = aiohttp.ProxyConnector(
    'http://proxy.example.com',
    proxy_auth=aiohttp.BasicAuth('user', 'pass'),
    loop=loop_mock
)
req = ClientRequest('GET', 'http://www.python.org')
await connector.connect(req)
```

In this scenario, the `ClientRequest` should be initialized with `auth=BasicAuth('user', 'pass')`. However, it is instead receiving `auth=BasicAuth(login=None, password=None)`.

**Expected Behavior:**
The `ClientRequest` should correctly receive the provided `BasicAuth` credentials (`user` and `pass`) when `proxy_auth` is specified. If no `proxy_auth` is provided, the `auth` parameter should be set to `None`.

**Actual Behavior:**
The `ClientRequest` receives `BasicAuth` with `login=None` and `password=None` even when valid credentials are provided through `proxy_auth`. This leads to failed authentication attempts with the proxy server.

[/ISSUE]
{
    "HttpConnectionTests.test_close": "PASSED",
    "HttpConnectionTests.test_del": "PASSED",
    "HttpConnectionTests.test_release": "PASSED",
    "BaseConnectorTests.test_cleanup": "PASSED",
    "BaseConnectorTests.test_close": "PASSED",
    "BaseConnectorTests.test_connect": "PASSED",
    "BaseConnectorTests.test_create_conn": "PASSED",
    "BaseConnectorTests.test_ctor_loop": "PASSED",
    "BaseConnectorTests.test_del": "PASSED",
    "BaseConnectorTests.test_get": "PASSED",
    "BaseConnectorTests.test_get_expired": "PASSED",
    "BaseConnectorTests.test_release": "PASSED",
    "BaseConnectorTests.test_release_close": "PASSED",
    "BaseConnectorTests.test_release_not_opened": "PASSED",
    "BaseConnectorTests.test_release_not_started": "PASSED",
    "BaseConnectorTests.test_start_cleanup_task": "PASSED",
    "BaseConnectorTests.test_tcp_connector_ctor": "PASSED",
    "ProxyConnectorTests.test_auth": "PASSED",
    "ProxyConnectorTests.test_auth__not_modifying_request": "PASSED",
    "ProxyConnectorTests.test_auth_from_url": "PASSED",
    "ProxyConnectorTests.test_connect": "PASSED",
    "ProxyConnectorTests.test_ctor": "PASSED",
    "ProxyConnectorTests.test_ctor2": "PASSED",
    "ProxyConnectorTests.test_https_connect": "PASSED",
    "ProxyConnectorTests.test_https_connect_http_proxy_error": "PASSED",
    "ProxyConnectorTests.test_https_connect_resp_start_error": "PASSED",
    "ProxyConnectorTests.test_https_connect_runtime_error": "PASSED",
    "ProxyConnectorTests.test_proxy_auth": "PASSED",
    "ProxyConnectorTests.test_proxy_connection_error": "PASSED",
    "ProxyConnectorTests.test_proxy_override_auth": "PASSED",
    "HttpClientConnectorTests.test_tcp_connector": "FAILED",
    "HttpClientConnectorTests.test_unix_connector": "FAILED"
}
diff --git a/aiohttp/connector.py b/aiohttp/connector.py
index 680062de..56bbc038 100644
--- a/aiohttp/connector.py
+++ b/aiohttp/connector.py
@@ -12,7 +12,7 @@ import weakref
 
 from .errors import HttpProxyError
 from .errors import ProxyConnectionError
-from .client import ClientRequest
+from .client import ClientRequest, BasicAuth
 
 
 class Connection(object):
@@ -274,14 +274,14 @@ class TCPConnector(BaseConnector):
 class ProxyConnector(TCPConnector):
     """Http Proxy connector."""
 
-    def __init__(self, proxy, proxy_login=None, proxy_passwd=None,
-                 *args, **kwargs):
+    def __init__(self, proxy, *args, proxy_auth=None, **kwargs):
         super().__init__(*args, **kwargs)
         self._proxy = proxy
-        self._basic_login = proxy_login
-        self._basic_passwd = proxy_passwd
+        self._proxy_auth = proxy_auth
         assert proxy.startswith('http://'), (
             "Only http proxy supported", proxy)
+        assert proxy_auth is None or isinstance(proxy_auth, BasicAuth), (
+            "proxy_auth must be None or BasicAuth() tuple", proxy_auth)
 
     @property
     def proxy(self):
@@ -292,7 +292,7 @@ class ProxyConnector(TCPConnector):
         proxy_req = ClientRequest(
             'GET', self._proxy,
             headers={'Host': req.host},
-            auth=aiohttp.BasicAuth(self._basic_login, self._basic_passwd),
+            auth=self._proxy_auth,
             loop=self._loop)
         try:
             transport, proto = yield from super()._create_connection(proxy_req)

{"aiohttp/connector.py": "__all__ = ['BaseConnector', 'TCPConnector', 'UnixConnector',\n           'SocketConnector', 'UnixSocketConnector', 'ProxyConnector']\n\nimport asyncio\nimport aiohttp\nimport functools\nimport http.cookies\nimport time\nimport ssl\nimport socket\nimport weakref\n\nfrom .errors import HttpProxyError\nfrom .errors import ProxyConnectionError\nfrom .client import ClientRequest\n\n\nclass Connection(object):\n\n    def __init__(self, connector, key, request, transport, protocol):\n        self._key = key\n        self._connector = connector\n        self._request = request\n        self._transport = transport\n        self._protocol = protocol\n        self.reader = protocol.reader\n        self.writer = protocol.writer\n        self._wr = weakref.ref(self, lambda wr, tr=self._transport: tr.close())\n\n    def close(self):\n        if self._transport is not None:\n            self._transport.close()\n            self._transport = None\n            self._wr = None\n\n    def release(self):\n        if self._transport:\n            self._connector._release(\n                self._key, self._request, self._transport, self._protocol)\n            self._transport = None\n            self._wr = None\n\n\nclass BaseConnector(object):\n\n    def __init__(self, *, conn_timeout=None, keepalive_timeout=30,\n                 share_cookies=False, force_close=False, loop=None, **kwargs):\n        self._conns = {}\n        self._conn_timeout = conn_timeout\n        self._keepalive_timeout = keepalive_timeout\n        self._share_cookies = share_cookies\n        self._cleanup_handle = None\n        self._force_close = force_close\n\n        if loop is None:\n            loop = asyncio.get_event_loop()\n        self._loop = loop\n        self._factory = functools.partial(aiohttp.StreamProtocol, loop=loop)\n\n        self.cookies = http.cookies.SimpleCookie()\n        self._wr = weakref.ref(\n            self, lambda wr, f=self._do_close, conns=self._conns: f(conns))\n\n    def _cleanup(self):\n        \"\"\"Cleanup unused transports.\"\"\"\n        if self._cleanup_handle:\n            self._cleanup_handle.cancel()\n            self._cleanup_handle = None\n\n        now = time.time()\n\n        connections = {}\n        for key, conns in self._conns.items():\n            alive = []\n            for transport, proto, t0 in conns:\n                if transport is not None:\n                    if proto and not proto.is_connected():\n                        transport = None\n                    elif (now - t0) > self._keepalive_timeout:\n                        transport.close()\n                        transport = None\n\n                if transport:\n                    alive.append((transport, proto, t0))\n            if alive:\n                connections[key] = alive\n\n        if connections:\n            self._cleanup_handle = self._loop.call_later(\n                self._keepalive_timeout, self._cleanup)\n\n        self._conns = connections\n        self._wr = weakref.ref(\n            self, lambda wr, f=self._do_close, conns=self._conns: f(conns))\n\n    def _start_cleanup_task(self):\n        if self._cleanup_handle is None:\n            self._cleanup_handle = self._loop.call_later(\n                self._keepalive_timeout, self._cleanup)\n\n    def close(self):\n        \"\"\"Close all opened transports.\"\"\"\n        self._do_close(self._conns)\n\n    @staticmethod\n    def _do_close(conns):\n        for key, data in conns.items():\n            for transport, proto, td in data:\n                transport.close()\n\n        conns.clear()\n\n    def update_cookies(self, cookies):\n        if isinstance(cookies, dict):\n            cookies = cookies.items()\n\n        for name, value in cookies:\n            if isinstance(value, http.cookies.Morsel):\n                # use dict method because SimpleCookie class modifies value\n                dict.__setitem__(self.cookies, name, value)\n            else:\n                self.cookies[name] = value\n\n    @asyncio.coroutine\n    def connect(self, req):\n        key = (req.host, req.port, req.ssl)\n\n        if self._share_cookies:\n            req.update_cookies(self.cookies.items())\n\n        transport, proto = self._get(key)\n        if transport is None:\n            if self._conn_timeout:\n                transport, proto = yield from asyncio.wait_for(\n                    self._create_connection(req),\n                    self._conn_timeout, loop=self._loop)\n            else:\n                transport, proto = yield from self._create_connection(req)\n\n        return Connection(self, key, req, transport, proto)\n\n    def _get(self, key):\n        conns = self._conns.get(key)\n        while conns:\n            transport, proto, t0 = conns.pop()\n            if transport is not None and proto.is_connected():\n                if (time.time() - t0) > self._keepalive_timeout:\n                    transport.close()\n                    transport = None\n                else:\n                    return transport, proto\n\n        return None, None\n\n    def _release(self, key, req, transport, protocol):\n        resp = req.response\n        should_close = False\n\n        if resp is not None:\n            if resp.message is None:\n                should_close = True\n            else:\n                should_close = resp.message.should_close\n                if self._share_cookies and resp.cookies:\n                    self.update_cookies(resp.cookies.items())\n\n        if self._force_close:\n            should_close = True\n\n        reader = protocol.reader\n        if should_close or (reader.output and not reader.output.at_eof()):\n            transport.close()\n        else:\n            conns = self._conns.get(key)\n            if conns is None:\n                conns = self._conns[key] = []\n            conns.append((transport, protocol, time.time()))\n            reader.unset_parser()\n\n            self._start_cleanup_task()\n\n    def _create_connection(self, req, *args, **kwargs):\n        raise NotImplementedError()\n\n\nclass TCPConnector(BaseConnector):\n\n    def __init__(self, *args, verify_ssl=True,\n                 resolve=False, family=socket.AF_INET, **kwargs):\n        super().__init__(*args, **kwargs)\n\n        self._verify_ssl = verify_ssl\n        self._family = family\n        self._resolve = resolve\n        self._resolved_hosts = {}\n\n    @property\n    def verify_ssl(self):\n        \"\"\"Do check for ssl certifications?\"\"\"\n        return self._verify_ssl\n\n    @property\n    def family(self):\n        \"\"\"Socket family like AF_INET\"\"\"\n        return self._family\n\n    @property\n    def resolve(self):\n        \"\"\"Do DNS lookup for host name?\"\"\"\n        return self._resolve\n\n    @property\n    def resolved_hosts(self):\n        \"\"\"The dict of (host, port) -> (ipaddr, port) pairs\"\"\"\n        return dict(self._resolved_hosts)\n\n    def clear_resolved_hosts(self, host=None, port=None):\n        if host is not None and port is not None:\n            key = (host, port)\n            if key in self._resolved_hosts:\n                del self._resolved_hosts[key]\n        else:\n            self._resolved_hosts.clear()\n\n    @asyncio.coroutine\n    def _resolve_host(self, host, port):\n        if self._resolve:\n            key = (host, port)\n\n            if key not in self._resolved_hosts:\n                infos = yield from self._loop.getaddrinfo(\n                    host, port, type=socket.SOCK_STREAM, family=self._family)\n\n                hosts = []\n                for family, _, proto, _, address in infos:\n                    hosts.append(\n                        {'hostname': host,\n                         'host': address[0], 'port': address[1],\n                         'family': family, 'proto': proto,\n                         'flags': socket.AI_NUMERICHOST})\n                self._resolved_hosts[key] = hosts\n\n            return list(self._resolved_hosts[key])\n        else:\n            return [{'hostname': host, 'host': host, 'port': port,\n                     'family': self._family, 'proto': 0, 'flags': 0}]\n\n    def _create_connection(self, req, **kwargs):\n        \"\"\"Create connection. Has same keyword arguments\n        as BaseEventLoop.create_connection\n        \"\"\"\n        sslcontext = req.ssl\n        if req.ssl and not self._verify_ssl:\n            sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)\n            sslcontext.options |= ssl.OP_NO_SSLv2\n            sslcontext.set_default_verify_paths()\n\n        hosts = yield from self._resolve_host(req.host, req.port)\n\n        while hosts:\n            hinfo = hosts.pop()\n            try:\n                return (yield from self._loop.create_connection(\n                    self._factory, hinfo['host'], hinfo['port'],\n                    ssl=sslcontext, family=hinfo['family'],\n                    proto=hinfo['proto'], flags=hinfo['flags'],\n                    server_hostname=hinfo['hostname'] if sslcontext else None,\n                    **kwargs))\n            except OSError:\n                if not hosts:\n                    raise\n\n\nclass ProxyConnector(TCPConnector):\n    \"\"\"Http Proxy connector.\"\"\"\n\n    def __init__(self, proxy, proxy_login=None, proxy_passwd=None,\n                 *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._proxy = proxy\n        self._basic_login = proxy_login\n        self._basic_passwd = proxy_passwd\n        assert proxy.startswith('http://'), (\n            \"Only http proxy supported\", proxy)\n\n    @property\n    def proxy(self):\n        return self._proxy\n\n    @asyncio.coroutine\n    def _create_connection(self, req, **kwargs):\n        proxy_req = ClientRequest(\n            'GET', self._proxy,\n            headers={'Host': req.host},\n            auth=aiohttp.BasicAuth(self._basic_login, self._basic_passwd),\n            loop=self._loop)\n        try:\n            transport, proto = yield from super()._create_connection(proxy_req)\n        except OSError as exc:\n            raise ProxyConnectionError(*exc.args) from exc\n        req.path = '{scheme}://{host}{path}'.format(scheme=req.scheme,\n                                                    host=req.host,\n                                                    path=req.path)\n        if 'AUTHORIZATION' in proxy_req.headers:\n            auth = proxy_req.headers['AUTHORIZATION']\n            del proxy_req.headers['AUTHORIZATION']\n            req.headers['PROXY-AUTHORIZATION'] = auth\n\n        if req.ssl:\n            # For HTTPS requests over HTTP proxy\n            # we must notify proxy to tunnel connection\n            # so we send CONNECT command:\n            #   CONNECT www.python.org:443 HTTP/1.1\n            #   Host: www.python.org\n            #\n            # next we must do TLS handshake and so on\n            # to do this we must wrap raw socket into secure one\n            # asyncio handles this perfectly\n            proxy_req.method = 'CONNECT'\n            proxy_req.path = '{}:{}'.format(req.host, req.port)\n            key = (req.host, req.port, req.ssl)\n            conn = Connection(self, key, proxy_req, transport, proto)\n            proxy_resp = proxy_req.send(conn.writer, conn.reader)\n            try:\n                resp = yield from proxy_resp.start(conn, True)\n            except:\n                proxy_resp.close()\n                conn.close()\n                raise\n            else:\n                if resp.status != 200:\n                    raise HttpProxyError(resp.status, resp.reason)\n                rawsock = transport.get_extra_info('socket', default=None)\n                if rawsock is None:\n                    raise RuntimeError(\n                        \"Transport does not expose socket instance\")\n                transport.pause_reading()\n                transport, proto = yield from self._loop.create_connection(\n                    self._factory, ssl=True, sock=rawsock,\n                    server_hostname=req.host, **kwargs)\n\n        return transport, proto\n\n\nclass UnixConnector(BaseConnector):\n\n    def __init__(self, path, *args, **kw):\n        super().__init__(*args, **kw)\n\n        self._path = path\n\n    @property\n    def path(self):\n        \"\"\"Path to unix socket\"\"\"\n        return self._path\n\n    @asyncio.coroutine\n    def _create_connection(self, req, **kwargs):\n        return (yield from self._loop.create_unix_connection(\n            self._factory, self._path, **kwargs))\n\n\nSocketConnector = TCPConnector\nUnixSocketConnector = UnixConnector\n"}
A user will ask you to solve a task. You should first draft your thinking process (inner monologue). Then, generate the solution.

Your response format must follow the template below:
<think>
Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate a correct solution.
</think>
<solution>
Final solution presented to the user.
</solution>
system
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** ProxyConnector Sets Incorrect Authentication Parameters in ClientRequest

**Description:**
After updating the `ProxyConnector` to use the `proxy_auth` parameter instead of separate `proxy_login` and `proxy_passwd`, certain authentication scenarios are not handled correctly. When initializing `ProxyConnector` with `proxy_auth`, the `ClientRequest` is inadvertently receiving `BasicAuth` with `login=None` and `password=None` instead of the intended credentials.

**Example Buggy Code:**
```python
connector = aiohttp.ProxyConnector(
    'http://proxy.example.com',
    proxy_auth=aiohttp.BasicAuth('user', 'pass'),
    loop=loop_mock
)
req = ClientRequest('GET', 'http://www.python.org')
await connector.connect(req)
```

In this scenario, the `ClientRequest` should be initialized with `auth=BasicAuth('user', 'pass')`. However, it is instead receiving `auth=BasicAuth(login=None, password=None)`.

**Expected Behavior:**
The `ClientRequest` should correctly receive the provided `BasicAuth` credentials (`user` and `pass`) when `proxy_auth` is specified. If no `proxy_auth` is provided, the `auth` parameter should be set to `None`.

**Actual Behavior:**
The `ClientRequest` receives `BasicAuth` with `login=None` and `password=None` even when valid credentials are provided through `proxy_auth`. This leads to failed authentication attempts with the proxy server.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### aiohttp/connector.py
__all__ = ['BaseConnector', 'TCPConnector', 'UnixConnector',
           'SocketConnector', 'UnixSocketConnector', 'ProxyConnector']

import asyncio
import aiohttp
import functools
import http.cookies
import time
import ssl
import socket
import weakref

from .errors import HttpProxyError
from .errors import ProxyConnectionError
from .client import ClientRequest


class Connection(object):

    def __init__(self, connector, key, request, transport, protocol):
        self._key = key
        self._connector = connector
        self._request = request
        self._transport = transport
        self._protocol = protocol
        self.reader = protocol.reader
        self.writer = protocol.writer
        self._wr = weakref.ref(self, lambda wr, tr=self._transport: tr.close())

    def close(self):
        if self._transport is not None:
            self._transport.close()
            self._transport = None
            self._wr = None

    def release(self):
        if self._transport:
            self._connector._release(
                self._key, self._request, self._transport, self._protocol)
            self._transport = None
            self._wr = None


class BaseConnector(object):

    def __init__(self, *, conn_timeout=None, keepalive_timeout=30,
                 share_cookies=False, force_close=False, loop=None, **kwargs):
        self._conns = {}
        self._conn_timeout = conn_timeout
        self._keepalive_timeout = keepalive_timeout
        self._share_cookies = share_cookies
        self._cleanup_handle = None
        self._force_close = force_close

        if loop is None:
            loop = asyncio.get_event_loop()
        self._loop = loop
        self._factory = functools.partial(aiohttp.StreamProtocol, loop=loop)

        self.cookies = http.cookies.SimpleCookie()
        self._wr = weakref.ref(
            self, lambda wr, f=self._do_close, conns=self._conns: f(conns))

    def _cleanup(self):
        """Cleanup unused transports."""
        if self._cleanup_handle:
            self._cleanup_handle.cancel()
            self._cleanup_handle = None

        now = time.time()

        connections = {}
        for key, conns in self._conns.items():
            alive = []
            for transport, proto, t0 in conns:
                if transport is not None:
                    if proto and not proto.is_connected():
                        transport = None
                    elif (now - t0) > self._keepalive_timeout:
                        transport.close()
                        transport = None

                if transport:
                    alive.append((transport, proto, t0))
            if alive:
                connections[key] = alive

        if connections:
            self._cleanup_handle = self._loop.call_later(
                self._keepalive_timeout, self._cleanup)

        self._conns = connections
        self._wr = weakref.ref(
            self, lambda wr, f=self._do_close, conns=self._conns: f(conns))

    def _start_cleanup_task(self):
        if self._cleanup_handle is None:
            self._cleanup_handle = self._loop.call_later(
                self._keepalive_timeout, self._cleanup)

    def close(self):
        """Close all opened transports."""
        self._do_close(self._conns)

    @staticmethod
    def _do_close(conns):
        for key, data in conns.items():
            for transport, proto, td in data:
                transport.close()

        conns.clear()

    def update_cookies(self, cookies):
        if isinstance(cookies, dict):
            cookies = cookies.items()

        for name, value in cookies:
            if isinstance(value, http.cookies.Morsel):
                # use dict method because SimpleCookie class modifies value
                dict.__setitem__(self.cookies, name, value)
            else:
                self.cookies[name] = value

    @asyncio.coroutine
    def connect(self, req):
        key = (req.host, req.port, req.ssl)

        if self._share_cookies:
            req.update_cookies(self.cookies.items())

        transport, proto = self._get(key)
        if transport is None:
            if self._conn_timeout:
                transport, proto = yield from asyncio.wait_for(
                    self._create_connection(req),
                    self._conn_timeout, loop=self._loop)
            else:
                transport, proto = yield from self._create_connection(req)

        return Connection(self, key, req, transport, proto)

    def _get(self, key):
        conns = self._conns.get(key)
        while conns:
            transport, proto, t0 = conns.pop()
            if transport is not None and proto.is_connected():
                if (time.time() - t0) > self._keepalive_timeout:
                    transport.close()
                    transport = None
                else:
                    return transport, proto

        return None, None

    def _release(self, key, req, transport, protocol):
        resp = req.response
        should_close = False

        if resp is not None:
            if resp.message is None:
                should_close = True
            else:
                should_close = resp.message.should_close
                if self._share_cookies and resp.cookies:
                    self.update_cookies(resp.cookies.items())

        if self._force_close:
            should_close = True

        reader = protocol.reader
        if should_close or (reader.output and not reader.output.at_eof()):
            transport.close()
        else:
            conns = self._conns.get(key)
            if conns is None:
                conns = self._conns[key] = []
            conns.append((transport, protocol, time.time()))
            reader.unset_parser()

            self._start_cleanup_task()

    def _create_connection(self, req, *args, **kwargs):
        raise NotImplementedError()


class TCPConnector(BaseConnector):

    def __init__(self, *args, verify_ssl=True,
                 resolve=False, family=socket.AF_INET, **kwargs):
        super().__init__(*args, **kwargs)

        self._verify_ssl = verify_ssl
        self._family = family
        self._resolve = resolve
        self._resolved_hosts = {}

    @property
    def verify_ssl(self):
        """Do check for ssl certifications?"""
        return self._verify_ssl

    @property
    def family(self):
        """Socket family like AF_INET"""
        return self._family

    @property
    def resolve(self):
        """Do DNS lookup for host name?"""
        return self._resolve

    @property
    def resolved_hosts(self):
        """The dict of (host, port) -> (ipaddr, port) pairs"""
        return dict(self._resolved_hosts)

    def clear_resolved_hosts(self, host=None, port=None):
        if host is not None and port is not None:
            key = (host, port)
            if key in self._resolved_hosts:
                del self._resolved_hosts[key]
        else:
            self._resolved_hosts.clear()

    @asyncio.coroutine
    def _resolve_host(self, host, port):
        if self._resolve:
            key = (host, port)

            if key not in self._resolved_hosts:
                infos = yield from self._loop.getaddrinfo(
                    host, port, type=socket.SOCK_STREAM, family=self._family)

                hosts = []
                for family, _, proto, _, address in infos:
                    hosts.append(
                        {'hostname': host,
                         'host': address[0], 'port': address[1],
                         'family': family, 'proto': proto,
                         'flags': socket.AI_NUMERICHOST})
                self._resolved_hosts[key] = hosts

            return list(self._resolved_hosts[key])
        else:
            return [{'hostname': host, 'host': host, 'port': port,
                     'family': self._family, 'proto': 0, 'flags': 0}]

    def _create_connection(self, req, **kwargs):
        """Create connection. Has same keyword arguments
        as BaseEventLoop.create_connection
        """
        sslcontext = req.ssl
        if req.ssl and not self._verify_ssl:
            sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
            sslcontext.options |= ssl.OP_NO_SSLv2
            sslcontext.set_default_verify_paths()

        hosts = yield from self._resolve_host(req.host, req.port)

        while hosts:
            hinfo = hosts.pop()
            try:
                return (yield from self._loop.create_connection(
                    self._factory, hinfo['host'], hinfo['port'],
                    ssl=sslcontext, family=hinfo['family'],
                    proto=hinfo['proto'], flags=hinfo['flags'],
                    server_hostname=hinfo['hostname'] if sslcontext else None,
                    **kwargs))
            except OSError:
                if not hosts:
                    raise


class ProxyConnector(TCPConnector):
    """Http Proxy connector."""

    def __init__(self, proxy, proxy_login=None, proxy_passwd=None,
                 *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._proxy = proxy
        self._basic_login = proxy_login
        self._basic_passwd = proxy_passwd
        assert proxy.startswith('http://'), (
            "Only http proxy supported", proxy)

    @property
    def proxy(self):
        return self._proxy

    @asyncio.coroutine
    def _create_connection(self, req, **kwargs):
        proxy_req = ClientRequest(
            'GET', self._proxy,
            headers={'Host': req.host},
            auth=aiohttp.BasicAuth(self._basic_login, self._basic_passwd),
            loop=self._loop)
        try:
            transport, proto = yield from super()._create_connection(proxy_req)
        except OSError as exc:
            raise ProxyConnectionError(*exc.args) from exc
        req.path = '{scheme}://{host}{path}'.format(scheme=req.scheme,
                                                    host=req.host,
                                                    path=req.path)
        if 'AUTHORIZATION' in proxy_req.headers:
            auth = proxy_req.headers['AUTHORIZATION']
            del proxy_req.headers['AUTHORIZATION']
            req.headers['PROXY-AUTHORIZATION'] = auth

        if req.ssl:
            # For HTTPS requests over HTTP proxy
            # we must notify proxy to tunnel connection
            # so we send CONNECT command:
            #   CONNECT www.python.org:443 HTTP/1.1
            #   Host: www.python.org
            #
            # next we must do TLS handshake and so on
            # to do this we must wrap raw socket into secure one
            # asyncio handles this perfectly
            proxy_req.method = 'CONNECT'
            proxy_req.path = '{}:{}'.format(req.host, req.port)
            key = (req.host, req.port, req.ssl)
            conn = Connection(self, key, proxy_req, transport, proto)
            proxy_resp = proxy_req.send(conn.writer, conn.reader)
            try:
                resp = yield from proxy_resp.start(conn, True)
            except:
                proxy_resp.close()
                conn.close()
                raise
            else:
                if resp.status != 200:
                    raise HttpProxyError(resp.status, resp.reason)
                rawsock = transport.get_extra_info('socket', default=None)
                if rawsock is None:
                    raise RuntimeError(
                        "Transport does not expose socket instance")
                transport.pause_reading()
                transport, proto = yield from self._loop.create_connection(
                    self._factory, ssl=True, sock=rawsock,
                    server_hostname=req.host, **kwargs)

        return transport, proto


class UnixConnector(BaseConnector):

    def __init__(self, path, *args, **kw):
        super().__init__(*args, **kw)

        self._path = path

    @property
    def path(self):
        """Path to unix socket"""
        return self._path

    @asyncio.coroutine
    def _create_connection(self, req, **kwargs):
        return (yield from self._loop.create_unix_connection(
            self._factory, self._path, **kwargs))


SocketConnector = TCPConnector
UnixSocketConnector = UnixConnector

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
user