]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Regression: Fix search when None is returned
authorThomas Steinacher <tom@eggdrop.ch>
Mon, 6 Apr 2015 14:40:44 +0000 (16:40 +0200)
committerThomas Steinacher <tom@eggdrop.ch>
Mon, 6 Apr 2015 14:40:44 +0000 (16:40 +0200)
imapclient/response_parser.py
imapclient/test/test_search.py

index 9cfc8a453c78b2c5b71ea9c0fb5d8eb9456a3adc..f4951053747ebec0b53120d5fa60697dc29bcb1d 100644 (file)
@@ -43,6 +43,8 @@ def parse_response(data):
 
     Returns nested tuples of appropriately typed objects.
     """
+    if data == [None]:
+        return []
     return tuple(gen_parsed_response(data))
 
 
index 362a94435f798b675aa6095ea3bd4b7dd5b2cb75..a25e32708f4a7a7cc12ce4f08e37bc9efec390b2 100644 (file)
@@ -16,6 +16,16 @@ class TestSearch(IMAPClientTest):
         self.assertEqual(result, [1, 2, 44])
         self.assertEqual(result.modseq, None)
 
+    def test_with_uid_none(self):
+        self.client.use_uid = True
+        self.client._imap.uid.return_value = ('OK', [None])
+
+        result = self.client.search('FOO')
+
+        self.client._imap.uid.assert_called_once_with('SEARCH', '(FOO)')
+        self.assertEqual(result, [])
+        self.assertEqual(result.modseq, None)
+
     def test_without_uid(self):
         self.client.use_uid = False
         self.client._imap.search.return_value = ('OK', [b'1 2 44'])