Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
39708de
Support helpers for running on non-IPv4 IPv6-only hosts.
gpshead May 17, 2021
aa9e7c5
Fixes eight testsuites to work on IPv6-only hosts.
gpshead May 17, 2021
ee00e8b
Make test_support pass on IPv6 only.
gpshead May 18, 2021
29efd49
Make test_os work on IPv6-only.
gpshead May 18, 2021
d51dc79
fix test_telnetlib IPv6-only, introduce get_family helper.
gpshead May 18, 2021
0c95594
Fix test_urllib2_localnet for IPv6-only.
gpshead May 18, 2021
7938fdc
tcp_socket() to replace socket.socket() in tests.
gpshead May 18, 2021
6436757
make test_ssl pass on IPv6-only.
gpshead May 18, 2021
d752f1a
cleanup a bit.
gpshead May 18, 2021
b726756
Make test_httplib pass IPv6-only.
gpshead May 18, 2021
66054f4
Make test_wsgiref pass on IPv6-only.
gpshead May 18, 2021
f20c40a
fix test_smtplib for IPv6-only.
gpshead May 18, 2021
8859b2a
Fix test_poplib for IPv6-only.
gpshead May 18, 2021
d485dc3
Make test_asyncore IPv6-only friendly.
gpshead May 18, 2021
77ed056
make test_asynchat IPv6-only friendly.
gpshead May 18, 2021
99e0665
Add udp_socket(), use SkipTest.
gpshead May 18, 2021
03aac81
Allow test_socket to work on IPv6-only hosts.
gpshead May 18, 2021
56d179e
cleanup test names to clarify IPv4 status.
gpshead May 18, 2021
7d55a83
Add AF_INET6 support to multiprocessing IPC.
gpshead May 19, 2021
1a72129
Fix test_httpservers for IPv6-only hosts.
gpshead May 19, 2021
bc6d51a
If starting a logging config server on AF_INET fails, try AF_INET6.
gpshead May 19, 2021
1317e7a
Fix test_logging for use on IPv6-only hosts.
gpshead May 19, 2021
6d50fa5
Make test_xmlrpc work on IPv6-only hosts rather than hang.
gpshead May 19, 2021
be88847
Prevent test_asyncio from hanging on an IPv6-only host.
gpshead May 19, 2021
5d0f8d7
Fix test_asyncio.test_streams to work on IPv6-only.
gpshead May 19, 2021
0b556da
Fix socket_helper sock vs tempsock paste error..
gpshead May 19, 2021
b7688e4
socket_helper typo (yes, find_unused_port is too ugly...)
gpshead May 19, 2021
2965d32
Undo find_unused_port complexity, use get_family()
gpshead May 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix test_asyncio.test_streams to work on IPv6-only.
  • Loading branch information
gpshead committed May 19, 2021
commit 5d0f8d786bc92c3804022b522f131991f9208894
30 changes: 17 additions & 13 deletions Lib/test/test_asyncio/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _basetest_open_connection(self, open_connection_fut):

def test_open_connection(self):
with test_utils.run_test_server() as httpd:
conn_fut = asyncio.open_connection(*httpd.address)
conn_fut = asyncio.open_connection(*httpd.address[:2])
self._basetest_open_connection(conn_fut)

@socket_helper.skip_unless_bind_unix_socket
Expand Down Expand Up @@ -84,8 +84,8 @@ def _basetest_open_connection_no_loop_ssl(self, open_connection_fut):
def test_open_connection_no_loop_ssl(self):
with test_utils.run_test_server(use_ssl=True) as httpd:
conn_fut = asyncio.open_connection(
*httpd.address,
ssl=test_utils.dummy_ssl_context())
*httpd.address[:2],
ssl=test_utils.dummy_ssl_context())

self._basetest_open_connection_no_loop_ssl(conn_fut)

Expand Down Expand Up @@ -115,7 +115,7 @@ def _basetest_open_connection_error(self, open_connection_fut):

def test_open_connection_error(self):
with test_utils.run_test_server() as httpd:
conn_fut = asyncio.open_connection(*httpd.address)
conn_fut = asyncio.open_connection(*httpd.address[:2])
self._basetest_open_connection_error(conn_fut)

@socket_helper.skip_unless_bind_unix_socket
Expand Down Expand Up @@ -582,19 +582,23 @@ async def handle_client(self, client_reader, client_writer):
await client_writer.wait_closed()

def start(self):
sock = socket.create_server(('127.0.0.1', 0))
sock = socket.create_server(
(socket_helper.HOST, 0),
family=socket_helper.get_family())
self.server = self.loop.run_until_complete(
asyncio.start_server(self.handle_client,
sock=sock))
return sock.getsockname()
return sock.getsockname()[:2]

def handle_client_callback(self, client_reader, client_writer):
self.loop.create_task(self.handle_client(client_reader,
client_writer))

def start_callback(self):
sock = socket.create_server(('127.0.0.1', 0))
addr = sock.getsockname()
sock = socket.create_server(
(socket_helper.HOST, 0),
family=socket_helper.get_family())
addr = sock.getsockname()[:2]
sock.close()
self.server = self.loop.run_until_complete(
asyncio.start_server(self.handle_client_callback,
Expand Down Expand Up @@ -909,7 +913,7 @@ def test_LimitOverrunError_pickleable(self):
def test_wait_closed_on_close(self):
with test_utils.run_test_server() as httpd:
rd, wr = self.loop.run_until_complete(
asyncio.open_connection(*httpd.address))
asyncio.open_connection(*httpd.address[:2]))

wr.write(b'GET / HTTP/1.0\r\n\r\n')
f = rd.readline()
Expand All @@ -926,7 +930,7 @@ def test_wait_closed_on_close(self):
def test_wait_closed_on_close_with_unread_data(self):
with test_utils.run_test_server() as httpd:
rd, wr = self.loop.run_until_complete(
asyncio.open_connection(*httpd.address))
asyncio.open_connection(*httpd.address[:2]))

wr.write(b'GET / HTTP/1.0\r\n\r\n')
f = rd.readline()
Expand All @@ -937,7 +941,7 @@ def test_wait_closed_on_close_with_unread_data(self):

def test_async_writer_api(self):
async def inner(httpd):
rd, wr = await asyncio.open_connection(*httpd.address)
rd, wr = await asyncio.open_connection(*httpd.address[:2])

wr.write(b'GET / HTTP/1.0\r\n\r\n')
data = await rd.readline()
Expand All @@ -957,7 +961,7 @@ async def inner(httpd):

def test_async_writer_api_exception_after_close(self):
async def inner(httpd):
rd, wr = await asyncio.open_connection(*httpd.address)
rd, wr = await asyncio.open_connection(*httpd.address[:2])

wr.write(b'GET / HTTP/1.0\r\n\r\n')
data = await rd.readline()
Expand All @@ -984,7 +988,7 @@ def test_eof_feed_when_closing_writer(self):

with test_utils.run_test_server() as httpd:
rd, wr = self.loop.run_until_complete(
asyncio.open_connection(*httpd.address))
asyncio.open_connection(*httpd.address[:2]))

wr.close()
f = wr.wait_closed()
Expand Down
8 changes: 5 additions & 3 deletions Lib/test/test_asyncio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import weakref

from unittest import mock
from test.support import socket_helper

from http.server import HTTPServer
from wsgiref.simple_server import WSGIRequestHandler, WSGIServer
Expand Down Expand Up @@ -140,6 +141,7 @@ def log_message(self, format, *args):

class SilentWSGIServer(WSGIServer):

address_family = socket_helper.get_family()
request_timeout = support.LOOPBACK_TIMEOUT

def get_request(self):
Expand Down Expand Up @@ -215,7 +217,7 @@ class UnixHTTPServer(socketserver.UnixStreamServer, HTTPServer):

def server_bind(self):
socketserver.UnixStreamServer.server_bind(self)
self.server_name = '127.0.0.1'
self.server_name = socket_helper.HOST
self.server_port = 80


Expand All @@ -236,7 +238,7 @@ def get_request(self):
# as the second return value will be a path;
# hence we return some fake data sufficient
# to get the tests going
return request, ('127.0.0.1', '')
return request, (socket_helper.HOST, '')


class SilentUnixWSGIServer(UnixWSGIServer):
Expand Down Expand Up @@ -275,7 +277,7 @@ def run_test_unix_server(*, use_ssl=False):


@contextlib.contextmanager
def run_test_server(*, host='127.0.0.1', port=0, use_ssl=False):
def run_test_server(*, host=socket_helper.HOST, port=0, use_ssl=False):
yield from _run_test_server(address=(host, port), use_ssl=use_ssl,
server_cls=SilentWSGIServer,
server_ssl_cls=SSLWSGIServer)
Expand Down