From: Menno Smits Date: Wed, 17 Apr 2013 22:48:29 +0000 (+0100) Subject: Log out secondary connnections without caring about errors X-Git-Tag: 0.10~2^2~21^2~1 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=cd3e9d90533222b270cdb01a7fc4e3517f3d6f16;p=imapclient.git Log out secondary connnections without caring about errors For some reason this is required by Fastmail.fm --- diff --git a/imapclient/livetest.py b/imapclient/livetest.py index 074d58d..79fc451 100644 --- a/imapclient/livetest.py +++ b/imapclient/livetest.py @@ -350,7 +350,7 @@ class TestGeneral(_TestBase): try: # Start a new connection and upload a new message client2 = create_client_from_config(self.conf) - self.addCleanup(client2.logout) + self.addCleanup(quiet_logout, client2) client2.select_folder(self.base_folder) client2.append(self.base_folder, SIMPLE_MESSAGE) @@ -392,7 +392,7 @@ class TestGeneral(_TestBase): # Start a new connection and upload a new message client2 = create_client_from_config(self.conf) - self.addCleanup(client2.logout) + self.addCleanup(quiet_logout, client2) client2.select_folder(self.base_folder) client2.append(self.base_folder, SIMPLE_MESSAGE) @@ -736,6 +736,14 @@ def createUidTestClass(conf, use_uid): return LiveTest +def quiet_logout(client): + """Log out a connection, ignoring errors (say because the connection is down) + """ + try: + client.logout() + except IMAPClient.Error: + pass + def lower_if_str(val): if isinstance(val, text_type): return val.lower()