]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Log out secondary connnections without caring about errors
authorMenno Smits <menno@freshfoo.com>
Wed, 17 Apr 2013 22:48:29 +0000 (23:48 +0100)
committerMenno Smits <menno@freshfoo.com>
Wed, 17 Apr 2013 22:48:29 +0000 (23:48 +0100)
For some reason this is required by Fastmail.fm

imapclient/livetest.py

index 074d58d2b54fa1bb069a91bd6f19e337835f2082..79fc451fcd952581d90d5b4961a6868e121943e4 100644 (file)
@@ -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()