This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xtreak
Recipients asvetlov, xtreak, yselivanov
Date 2019-12-24.11:23:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1577186595.84.0.0970776256712.issue39129@roundup.psfhosted.org>
In-reply-to
Content
Is there a way this can be tested? I tried simulating OSError for IPv4 address and returning socket for ipv6 one like it resolves correctly. I guess that's the underlying idea of happy eyeballs but a test can be added for basic workflow since it lacks tests.

@patch_socket
def test_create_connection_happy_eyeballs_exception(self, sock_mock):
    async def getaddrinfo(*args, **kw):
        return [(2, 1, 6, '', ('127.0.0.1', 8000)),
                (2, 1, 6, '', ('::1', 8000, 0, 0)),]

    def getaddrinfo_task(*args, **kwds):
        return self.loop.create_task(getaddrinfo(*args, **kwds))

    self.loop.getaddrinfo = getaddrinfo_task
    with mock.patch.object(self.loop, 'sock_connect',
                           side_effect=[OSError, sock_mock]):
        coro = self.loop.create_connection(MyProto, host='localhost', port=8000,
                                           happy_eyeballs_delay=1)
        transport, _ = self.loop.run_until_complete(coro)
        transport.close()
History
Date User Action Args
2019-12-24 11:23:15xtreaksetrecipients: + xtreak, asvetlov, yselivanov
2019-12-24 11:23:15xtreaksetmessageid: <1577186595.84.0.0970776256712.issue39129@roundup.psfhosted.org>
2019-12-24 11:23:15xtreaklinkissue39129 messages
2019-12-24 11:23:15xtreakcreate