[issue39129] Incorrect import of TimeoutError while creating happy eyeballs connection
Karthikeyan Singaravelan
report at bugs.python.org
Tue Dec 24 06:23:15 EST 2019
Karthikeyan Singaravelan <tir.karthi at gmail.com> added the comment:
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()
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39129>
_______________________________________
More information about the Python-bugs-list
mailing list