diff --git a/tests/test_connector.py b/tests/test_connector.py index bbe77f2a70..f28545b08e 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -728,9 +728,15 @@ def get_extra_info(param): assert False - conn._loop.create_connection = create_connection - - with mock.patch( + 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 ): established_connection = await conn.connect(req, [], ClientTimeout()) @@ -880,9 +886,15 @@ async def create_connection(*args, **kwargs): pr = create_mocked_conn(loop) return tr, pr - conn._loop.create_connection = create_connection - - with mock.patch( + 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 ): established_connection = await conn.connect(req, [], ClientTimeout())