summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-05-18 06:42:25 (GMT)
committerGitHub <noreply@github.com>2020-05-18 06:42:25 (GMT)
commit94d9c5e5afdee4f46be9d9faaa39d6be40c34849 (patch)
tree9eb6060cd253338cfdc338648bda908034043baf /Lib/test/test_asyncio
parentc1f1ddf30a595c2bfa3c06e54fb03fa212cd28b5 (diff)
downloadcpython-94d9c5e5afdee4f46be9d9faaa39d6be40c34849.zip
cpython-94d9c5e5afdee4f46be9d9faaa39d6be40c34849.tar.gz
cpython-94d9c5e5afdee4f46be9d9faaa39d6be40c34849.tar.bz2
bpo-39148: enable ipv6 for datagrams in Proactor (GH-19121)
Ifdef is not necessary, as AF_INET6 is supported from Windows Vista, and other code in overlapped.c uses AF_INET6 and is not ifdef'd. Change the raised exception so users are not fooled to think it comes from Windows API. Automerge-Triggered-By: @njsmith (cherry picked from commit 442634c42fcaf31c636f693951a97734042c3e7b) Co-authored-by: Kjell Braden <afflux@pentabarf.de>
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r--Lib/test/test_asyncio/test_events.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index aec56da..37f1cb7 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -1204,7 +1204,7 @@ class EventLoopTestsMixin:
ConnectionRefusedError, client.connect, ('127.0.0.1', port))
client.close()
- def test_create_datagram_endpoint(self):
+ def _test_create_datagram_endpoint(self, local_addr, family):
class TestMyDatagramProto(MyDatagramProto):
def __init__(inner_self):
super().__init__(loop=self.loop)
@@ -1214,9 +1214,11 @@ class EventLoopTestsMixin:
self.transport.sendto(b'resp:'+data, addr)
coro = self.loop.create_datagram_endpoint(
- TestMyDatagramProto, local_addr=('127.0.0.1', 0))
+ TestMyDatagramProto, local_addr=local_addr, family=family)
s_transport, server = self.loop.run_until_complete(coro)
- host, port = s_transport.get_extra_info('sockname')
+ sockname = s_transport.get_extra_info('sockname')
+ host, port = socket.getnameinfo(
+ sockname, socket.NI_NUMERICHOST|socket.NI_NUMERICSERV)
self.assertIsInstance(s_transport, asyncio.Transport)
self.assertIsInstance(server, TestMyDatagramProto)
@@ -1250,6 +1252,13 @@ class EventLoopTestsMixin:
self.assertEqual('CLOSED', client.state)
server.transport.close()
+ def test_create_datagram_endpoint(self):
+ self._test_create_datagram_endpoint(('127.0.0.1', 0), socket.AF_INET)
+
+ @unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 not supported or enabled')
+ def test_create_datagram_endpoint_ipv6(self):
+ self._test_create_datagram_endpoint(('::1', 0), socket.AF_INET6)
+
def test_create_datagram_endpoint_sock(self):
sock = None
local_address = ('127.0.0.1', 0)