Skip to content

Commit

Permalink
Reduce indent in connector tests (#9371)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Oct 1, 2024
1 parent a9ac5e2 commit c25099c
Showing 1 changed file with 29 additions and 33 deletions.
62 changes: 29 additions & 33 deletions tests/test_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,29 +790,27 @@ def get_extra_info(param: str) -> object:

with mock.patch.object(
conn, "_resolve_host", autospec=True, spec_set=True, side_effect=_resolve_host
), mock.patch.object(
conn._loop,
"create_connection",
autospec=True,
spec_set=True,
side_effect=create_connection,
), mock.patch(
"aiohttp.connector.aiohappyeyeballs.start_connection", start_connection
):
with mock.patch.object(
conn._loop,
"create_connection",
autospec=True,
spec_set=True,
side_effect=create_connection,
):
with mock.patch(
"aiohttp.connector.aiohappyeyeballs.start_connection", start_connection
):
established_connection = await conn.connect(req, [], ClientTimeout())
established_connection = await conn.connect(req, [], ClientTimeout())

assert ips_tried == ips
assert addrs_tried == [(ip, 443) for ip in ips]
assert ips_tried == ips
assert addrs_tried == [(ip, 443) for ip in ips]

assert os_error
assert certificate_error
assert ssl_error
assert fingerprint_error
assert connected
assert os_error
assert certificate_error
assert ssl_error
assert fingerprint_error
assert connected

established_connection.close()
established_connection.close()


@pytest.mark.parametrize(
Expand Down Expand Up @@ -970,22 +968,20 @@ async def create_connection(

with mock.patch.object(
conn, "_resolve_host", autospec=True, spec_set=True, side_effect=_resolve_host
), mock.patch.object(
conn._loop,
"create_connection",
autospec=True,
spec_set=True,
side_effect=create_connection,
), mock.patch(
"aiohttp.connector.aiohappyeyeballs.start_connection", start_connection
):
with mock.patch.object(
conn._loop,
"create_connection",
autospec=True,
spec_set=True,
side_effect=create_connection,
):
with mock.patch(
"aiohttp.connector.aiohappyeyeballs.start_connection", start_connection
):
established_connection = await conn.connect(req, [], ClientTimeout())
established_connection = await conn.connect(req, [], ClientTimeout())

assert success_ips == [ip4]
assert interleave_val == 2
established_connection.close()
assert success_ips == [ip4]
assert interleave_val == 2
established_connection.close()


async def test_tcp_connector_family_is_respected(
Expand Down

0 comments on commit c25099c

Please sign in to comment.