Message358847
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() |
|
Date |
User |
Action |
Args |
2019-12-24 11:23:15 | xtreak | set | recipients:
+ xtreak, asvetlov, yselivanov |
2019-12-24 11:23:15 | xtreak | set | messageid: <1577186595.84.0.0970776256712.issue39129@roundup.psfhosted.org> |
2019-12-24 11:23:15 | xtreak | link | issue39129 messages |
2019-12-24 11:23:15 | xtreak | create | |
|