Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions Lib/test/test_asyncio/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,14 @@ def start_tls(self, ssl_context, *,
server_hostname=server_hostname,
do_handshake_on_connect=False)

ssl_sock.do_handshake()
try:
ssl_sock.do_handshake()
except:
ssl_sock.close()
raise
finally:
self.__sock.close()

self.__sock.close()
self.__sock = ssl_sock

def __getattr__(self, name):
Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_asyncio/test_sslproto.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,8 @@ def server(sock):
server_side=True)
except ssl.SSLError:
pass
except OSError:
pass
finally:
sock.close()

Expand Down Expand Up @@ -636,6 +638,7 @@ def server(sock):
except ssl.SSLError:
pass
finally:
orig_sock.close()
sock.close()

async def client(addr):
Expand All @@ -649,6 +652,8 @@ async def client(addr):
writer.write(b'B')
with self.assertRaises(ssl.SSLError):
await reader.readline()

writer.close()
return 'OK'

with self.tcp_server(server,
Expand Down
9 changes: 7 additions & 2 deletions Lib/test/test_asyncio/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,11 @@ def coro():
self.assertFalse(m_log.error.called)

with self.assertRaises(ValueError):
self.new_task(self.loop, coro())
gen = coro()
try:
self.new_task(self.loop, gen)
finally:
gen.close()

self.assertTrue(m_log.error.called)
message = m_log.error.call_args[0][0]
Expand Down Expand Up @@ -2609,7 +2613,8 @@ def done(self):
self.assertEqual(asyncio.all_tasks(loop), set())
self._register_task(task)
self.assertEqual(asyncio.all_tasks(loop), set())
self.assertEqual(asyncio.Task.all_tasks(loop), {task})
with self.assertWarns(PendingDeprecationWarning):
self.assertEqual(asyncio.Task.all_tasks(loop), {task})
self._unregister_task(task)

def test__enter_task(self):
Expand Down