Skip to content
Merged
Changes from all commits
Commits
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
26 changes: 16 additions & 10 deletions Lib/test/test_asyncio/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,12 +1202,13 @@ def test_create_server_ssl_verify_failed(self):
'(?i)certificate.verify.failed'):
self.loop.run_until_complete(f_c)

# execute the loop to log the connection error
test_utils.run_briefly(self.loop)
# close connection: wait until the server-side transport of the
# failed handshake is closed as well, otherwise its socket may
# still be open when the loop is closed (gh-159123).
server.close()
self.loop.run_until_complete(server.wait_closed())

# close connection
self.assertIsNone(proto.transport)
server.close()

@socket_helper.skip_unless_bind_unix_socket
@unittest.skipIf(ssl is None, 'No ssl module')
Expand All @@ -1232,12 +1233,13 @@ def test_create_unix_server_ssl_verify_failed(self):
'(?i)certificate.verify.failed'):
self.loop.run_until_complete(f_c)

# execute the loop to log the connection error
test_utils.run_briefly(self.loop)
# close connection: wait until the server-side transport of the
# failed handshake is closed as well, otherwise its socket may
# still be open when the loop is closed (gh-159123).
server.close()
self.loop.run_until_complete(server.wait_closed())

# close connection
self.assertIsNone(proto.transport)
server.close()

@unittest.skipIf(ssl is None, 'No ssl module')
def test_create_server_ssl_match_failed(self):
Expand Down Expand Up @@ -1268,10 +1270,14 @@ def test_create_server_ssl_match_failed(self):
with self.assertRaisesRegex(ssl.CertificateError, regex):
self.loop.run_until_complete(f_c)

# close connection
# close connection: wait until the server-side transport of the
# failed handshake is closed as well, otherwise its socket may
# still be open when the loop is closed (gh-159123).
server.close()
self.loop.run_until_complete(server.wait_closed())

# transport is None because TLS ALERT aborted the handshake
self.assertIsNone(proto.transport)
server.close()

@socket_helper.skip_unless_bind_unix_socket
@unittest.skipIf(ssl is None, 'No ssl module')
Expand Down
Loading