Better handling of connections closed by clients.

This commit is contained in:
2021-02-20 10:43:00 +01:00
parent c4a9592156
commit fe694487c7
2 changed files with 6 additions and 2 deletions

View File

@ -113,7 +113,11 @@ class BaseClientTestCase(_IrcTestCase):
self._setUpServer() self._setUpServer()
def tearDown(self): def tearDown(self):
if self.conn: if self.conn:
self.conn.sendall(b'QUIT :end of test.') try:
self.conn.sendall(b'QUIT :end of test.')
except BrokenPipeError:
# client already disconnected
pass
self.controller.kill() self.controller.kill()
if self.conn: if self.conn:
self.conn_file.close() self.conn_file.close()

View File

@ -139,5 +139,5 @@ class TlsTestCase(cases.BaseClientTestCase):
tls_config=tls_config, tls_config=tls_config,
) )
self.acceptClient(tls_cert=BAD_CERT, tls_key=BAD_KEY) self.acceptClient(tls_cert=BAD_CERT, tls_key=BAD_KEY)
with self.assertRaises(ConnectionClosed): with self.assertRaises((ConnectionClosed, ConnectionResetError)):
m = self.getMessage() m = self.getMessage()