async def _wrap_create_socks_connection(self, *args, req, **kwargs): try: return await create_connection(*args, **kwargs) except certificate_errors as exc: raise aiohttp.ClientConnectorCertificateError( req.connection_key, exc) from exc except ssl_errors as exc: raise aiohttp.ClientConnectorSSLError(req.connection_key, exc) from exc except (OSError, SocksConnectionError) as exc: raise aiohttp.ClientProxyConnectionError(req.connection_key, exc) from exc
async def test_perform_request_ssl_error(auto_close, loop): for exc, expected in [ (aiohttp.ClientConnectorCertificateError(mock.Mock(), mock.Mock()), SSLError), # noqa (aiohttp.ClientConnectorSSLError(mock.Mock(), mock.Mock()), SSLError), (aiohttp.ClientSSLError(mock.Mock(), mock.Mock()), SSLError), (aiohttp.ClientError('Other'), ConnectionError), (asyncio.TimeoutError, ConnectionTimeout), ]: session = aiohttp.ClientSession(loop=loop) session._request = make_mocked_coro(raise_exception=exc) conn = auto_close(AIOHttpConnection(session=session, loop=loop, use_ssl=True)) with pytest.raises(expected): await conn.perform_request('HEAD', '/')