]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Handle empty strings and None's in the folder list responses again
authorMenno Smits <menno@freshfoo.com>
Mon, 8 Feb 2010 13:06:35 +0000 (13:06 +0000)
committerMenno Smits <menno@freshfoo.com>
Mon, 8 Feb 2010 13:06:35 +0000 (13:06 +0000)
All tests passing.

imapclient/imapclient.py
imapclient/test/test_IMAPClient.py

index 46b4093cdf11c02f21cb48401e7ee0de5b7cfcd1..7fa048e238b0c09f7e34a11146d7d0f3eba96616 100644 (file)
@@ -204,10 +204,11 @@ class IMAPClient(object):
         return self._proc_folder_list(dat)
 
     def _proc_folder_list(self, folder_data):
-        # appears to be a special case - no 'untagged' responses (ie, no
-        # folders) returns [None]
-        if folder_data == [None]:
-            return []
+        # Filter out empty strings and None's.
+        # This also deals with the special case of - no 'untagged'
+        # responses (ie, no folders). This comes back as [None].
+        folder_data = [item for item in folder_data if item not in ('', None)]
+
         ret = []
         parsed = parse_response(folder_data)
         while parsed:
index a6672b252193111bf8c60a1ef1796de3f603768a..7f2087b7635aafb8935db7d24d9721693701fb18 100644 (file)
@@ -96,11 +96,13 @@ class TestListFolders(IMAPClientTest):
                                    (['\\HasNoChildren'], '/', 'Left\"Right'),
                                    (['\\HasNoChildren'], '/', r'Left\Right')])
 
+    def test_empty_response(self):
+        self.assertEqual(self.client._proc_folder_list([None]), [])
+
+
     def test_blanks(self):
-        folders = self.client._proc_folder_list(['', None, 
-                                                 r'(\\HasNoChildren) "/" "last"',
-                                                ])
-        self.assert_(folders == ['last'], 'got %r' % folders)
+        folders = self.client._proc_folder_list(['', None, r'(\HasNoChildren) "/" "last"'])
+        self.assertEqual(folders, [([r'\HasNoChildren'], '/', 'last')])
 
 
 class TestAppend(IMAPClientTest):