From 857e8d195e03701a8721efe116b5959c6179f22d Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Tue, 22 Oct 2019 18:28:39 +0200 Subject: [PATCH] Fix exception handling in testUntrustedCertificate on closed connection. --- irctest/cases.py | 5 ++++- irctest/client_tests/test_tls.py | 2 +- irctest/controllers/limnoria.py | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/irctest/cases.py b/irctest/cases.py index 3315004..e9d8129 100644 --- a/irctest/cases.py +++ b/irctest/cases.py @@ -98,7 +98,10 @@ class BaseClientTestCase(_IrcTestCase): self._setUpServer() def tearDown(self): if self.conn: - self.conn.sendall(b'QUIT :end of test.') + try: + self.conn.sendall(b'QUIT :end of test.') + except BrokenPipeError: + pass # client disconnected before we did self.controller.kill() if self.conn: self.conn_file.close() diff --git a/irctest/client_tests/test_tls.py b/irctest/client_tests/test_tls.py index 737fa2e..5b47362 100644 --- a/irctest/client_tests/test_tls.py +++ b/irctest/client_tests/test_tls.py @@ -139,5 +139,5 @@ class TlsTestCase(cases.BaseClientTestCase): tls_config=tls_config, ) self.acceptClient(tls_cert=BAD_CERT, tls_key=BAD_KEY) - with self.assertRaises(ConnectionClosed): + with self.assertRaises((ConnectionClosed, ConnectionResetError)): m = self.getMessage() diff --git a/irctest/controllers/limnoria.py b/irctest/controllers/limnoria.py index 848ea75..a00cd1b 100644 --- a/irctest/controllers/limnoria.py +++ b/irctest/controllers/limnoria.py @@ -62,7 +62,8 @@ class LimnoriaController(BaseClientController, DirectoryBasedController): trusted_fingerprints=' '.join(tls_config.trusted_fingerprints) if tls_config else '', )) self.proc = subprocess.Popen(['supybot', - os.path.join(self.directory, 'bot.conf')]) + os.path.join(self.directory, 'bot.conf')], + stderr=subprocess.STDOUT) def get_irctest_controller_class(): return LimnoriaController