bpo-33789: test_asyncio: Fix ResourceWarning (GH-7460)

* Close sockets and streams to fix ResourceWarning warnings
* Catch also OSError to hide a traceback on an expected handshake
  error
This commit is contained in:
Victor Stinner 2018-06-07 01:12:38 +02:00 committed by GitHub
parent 3ef769fcd3
commit 0eba7c3913
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -150,9 +150,14 @@ class TestSocketWrapper:
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):