Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 19, 2023
1 parent 0cd16ea commit a0b52a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
16 changes: 11 additions & 5 deletions tests/test_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,14 @@ async def test_tcp_connector_server_hostname_default(loop) -> None:
conn = aiohttp.TCPConnector(loop=loop)

conn._loop.create_connection = mock.AsyncMock()
conn._loop.create_connection.return_value = mock.Mock(), mock.Mock()
conn._loop.create_connection.return_value = mock.Mock(), mock.Mock()

req = ClientRequest("GET", URL("https://127.0.0.1:443"), loop=loop)

established_connection = await conn.connect(req, [], ClientTimeout())
assert conn._loop.create_connection.call_args.kwargs["server_hostname"] == "127.0.0.1"
assert (
conn._loop.create_connection.call_args.kwargs["server_hostname"] == "127.0.0.1"
)

established_connection.close()

Expand All @@ -575,12 +577,16 @@ async def test_tcp_connector_server_hostname_override(loop) -> None:
conn = aiohttp.TCPConnector(loop=loop)

conn._loop.create_connection = mock.AsyncMock()
conn._loop.create_connection.return_value = mock.Mock(), mock.Mock()
conn._loop.create_connection.return_value = mock.Mock(), mock.Mock()

req = ClientRequest("GET", URL("https://127.0.0.1:443"), loop=loop, server_hostname="localhost")
req = ClientRequest(
"GET", URL("https://127.0.0.1:443"), loop=loop, server_hostname="localhost"
)

established_connection = await conn.connect(req, [], ClientTimeout())
assert conn._loop.create_connection.call_args.kwargs["server_hostname"] == "localhost"
assert (
conn._loop.create_connection.call_args.kwargs["server_hostname"] == "localhost"
)

established_connection.close()

Expand Down
13 changes: 10 additions & 3 deletions tests/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ async def make_conn():
connector._create_connection(req, None, aiohttp.ClientTimeout())
)

self.assertEqual(self.loop.start_tls.call_args.kwargs["server_hostname"], "www.python.org")
self.assertEqual(
self.loop.start_tls.call_args.kwargs["server_hostname"], "www.python.org"
)

self.loop.run_until_complete(proxy_req.close())
proxy_resp.close()
Expand All @@ -247,7 +249,9 @@ async def make_conn():
@mock.patch("aiohttp.connector.ClientRequest")
def test_proxy_server_hostname_override(self, ClientRequestMock) -> None:
proxy_req = ClientRequest(
"GET", URL("http://proxy.example.com"), loop=self.loop,
"GET",
URL("http://proxy.example.com"),
loop=self.loop,
)
ClientRequestMock.return_value = proxy_req

Expand Down Expand Up @@ -297,7 +301,10 @@ async def make_conn():
connector._create_connection(req, None, aiohttp.ClientTimeout())
)

self.assertEqual(self.loop.start_tls.call_args.kwargs["server_hostname"], "server-hostname.example.com")
self.assertEqual(
self.loop.start_tls.call_args.kwargs["server_hostname"],
"server-hostname.example.com",
)

self.loop.run_until_complete(proxy_req.close())
proxy_resp.close()
Expand Down

0 comments on commit a0b52a3

Please sign in to comment.