gh-90978: asyncio TestSSL uses SHORT_TIMEOUT (GH-92642)

TestSSL of asyncio now uses support.SHORT_TIMEOUT rather than
hardcoded timeouts like 5, 10 or 40 seconds.
(cherry picked from commit 1d1929fcb5)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Miss Islington (bot) 2022-05-11 14:56:07 -07:00 committed by GitHub
parent 5a33643dce
commit 64593f2fed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -82,7 +82,7 @@ class TestSSL(test_utils.TestCase):
def tcp_server(self, server_prog, *, def tcp_server(self, server_prog, *,
family=socket.AF_INET, family=socket.AF_INET,
addr=None, addr=None,
timeout=5, timeout=support.SHORT_TIMEOUT,
backlog=1, backlog=1,
max_clients=10): max_clients=10):
@ -113,7 +113,7 @@ class TestSSL(test_utils.TestCase):
def tcp_client(self, client_prog, def tcp_client(self, client_prog,
family=socket.AF_INET, family=socket.AF_INET,
timeout=10): timeout=support.SHORT_TIMEOUT):
sock = socket.socket(family, socket.SOCK_STREAM) sock = socket.socket(family, socket.SOCK_STREAM)
@ -238,7 +238,7 @@ class TestSSL(test_utils.TestCase):
async def start_server(): async def start_server():
extras = {} extras = {}
extras = dict(ssl_handshake_timeout=40.0) extras = dict(ssl_handshake_timeout=support.SHORT_TIMEOUT)
srv = await asyncio.start_server( srv = await asyncio.start_server(
handle_client, handle_client,
@ -303,7 +303,7 @@ class TestSSL(test_utils.TestCase):
async def client(addr): async def client(addr):
extras = {} extras = {}
extras = dict(ssl_handshake_timeout=40.0) extras = dict(ssl_handshake_timeout=support.SHORT_TIMEOUT)
reader, writer = await asyncio.open_connection( reader, writer = await asyncio.open_connection(
*addr, *addr,
@ -428,7 +428,7 @@ class TestSSL(test_utils.TestCase):
*addr, *addr,
ssl=client_sslctx, ssl=client_sslctx,
server_hostname='', server_hostname='',
ssl_handshake_timeout=1.0) ssl_handshake_timeout=support.SHORT_TIMEOUT)
writer.close() writer.close()
await self.wait_closed(writer) await self.wait_closed(writer)
@ -590,7 +590,7 @@ class TestSSL(test_utils.TestCase):
extras = {} extras = {}
if server_ssl: if server_ssl:
extras = dict(ssl_handshake_timeout=10.0) extras = dict(ssl_handshake_timeout=support.SHORT_TIMEOUT)
f = loop.create_task( f = loop.create_task(
loop.connect_accepted_socket( loop.connect_accepted_socket(
@ -718,7 +718,8 @@ class TestSSL(test_utils.TestCase):
with self.tcp_server(serve, timeout=self.TIMEOUT) as srv: with self.tcp_server(serve, timeout=self.TIMEOUT) as srv:
self.loop.run_until_complete( self.loop.run_until_complete(
asyncio.wait_for(client(srv.addr), timeout=10)) asyncio.wait_for(client(srv.addr),
timeout=support.SHORT_TIMEOUT))
def test_create_connection_memory_leak(self): def test_create_connection_memory_leak(self):
HELLO_MSG = b'1' * self.PAYLOAD_SIZE HELLO_MSG = b'1' * self.PAYLOAD_SIZE
@ -776,7 +777,8 @@ class TestSSL(test_utils.TestCase):
with self.tcp_server(serve, timeout=self.TIMEOUT) as srv: with self.tcp_server(serve, timeout=self.TIMEOUT) as srv:
self.loop.run_until_complete( self.loop.run_until_complete(
asyncio.wait_for(client(srv.addr), timeout=10)) asyncio.wait_for(client(srv.addr),
timeout=support.SHORT_TIMEOUT))
# No garbage is left for SSL client from loop.create_connection, even # No garbage is left for SSL client from loop.create_connection, even
# if user stores the SSLTransport in corresponding protocol instance # if user stores the SSLTransport in corresponding protocol instance
@ -936,7 +938,8 @@ class TestSSL(test_utils.TestCase):
with self.tcp_server(serve, timeout=self.TIMEOUT) as srv: with self.tcp_server(serve, timeout=self.TIMEOUT) as srv:
self.loop.run_until_complete( self.loop.run_until_complete(
asyncio.wait_for(client(srv.addr), timeout=10)) asyncio.wait_for(client(srv.addr),
timeout=support.SHORT_TIMEOUT))
def test_start_tls_server_1(self): def test_start_tls_server_1(self):
HELLO_MSG = b'1' * self.PAYLOAD_SIZE HELLO_MSG = b'1' * self.PAYLOAD_SIZE
@ -1186,7 +1189,7 @@ class TestSSL(test_utils.TestCase):
async def client(addr): async def client(addr):
extras = {} extras = {}
extras = dict(ssl_handshake_timeout=10.0) extras = dict(ssl_handshake_timeout=support.SHORT_TIMEOUT)
reader, writer = await asyncio.open_connection( reader, writer = await asyncio.open_connection(
*addr, *addr,