self.sslsock.do_handshake.side_effect = exc
with test_utils.disable_logger():
transport._on_handshake(0)
+ transport.close()
+ test_utils.run_briefly(self.loop)
def test_pause_resume_reading(self):
tr = self._make_one()
waiter.cancel()
transport = mock.Mock()
sslpipe = mock.Mock()
+ sslpipe.shutdown.return_value = b''
sslpipe.do_handshake.side_effect = do_handshake
with mock.patch('asyncio.sslproto._SSLPipe', return_value=sslpipe):
ssl_proto.connection_made(transport)
with test_utils.disable_logger():
self.loop.run_until_complete(handshake_fut)
+ # Close the transport
+ ssl_proto._app_transport.close()
+
if __name__ == '__main__':
unittest.main()
# "Exception during subprocess creation, kill the subprocess"
with test_utils.disable_logger():
self.loop.run_until_complete(cancel_make_transport())
+ test_utils.run_briefly(self.loop)
if sys.platform != 'win32':
import socket
import sys
import unittest
+import warnings
from unittest import mock
if sys.platform != 'win32':
self.assertEqual(p.handle, h)
# check garbage collection of p closes handle
- del p
- support.gc_collect()
+ with warnings.catch_warnings():
+ warnings.filterwarnings("ignore", "", ResourceWarning)
+ del p
+ support.gc_collect()
try:
_winapi.CloseHandle(h)
except OSError as e:
self.assertTrue(msg.upper().rstrip().startswith(out))
self.assertTrue(b"stderr".startswith(err))
- p.wait()
+ # The context manager calls wait() and closes resources
+ with p:
+ pass
if __name__ == '__main__':