]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Fixed dict normalisation in livetests
authorMenno Smits <menno@freshfoo.com>
Tue, 8 Sep 2015 02:35:23 +0000 (14:35 +1200)
committerMenno Smits <menno@freshfoo.com>
Tue, 8 Sep 2015 02:35:23 +0000 (14:35 +1200)
Use _dict_bytes_normaliser instead of (now removed)
normalise_untagged_responses.

imapclient/imapclient.py
imapclient/livetest.py

index 1b63ccb817c7728f5f96156be9db4e79891ca008..56e2abd891b62ca6e1a91ed3876163257158c616 100644 (file)
@@ -1382,10 +1382,16 @@ class _dict_bytes_normaliser(object):
     # For Python 3 compatibility.
     items = iteritems
 
+    def __contains__(self, ink):
+        for k in self._gen_keys(ink):
+            if k in self._d:
+                return True
+        return False
+
     def get(self, ink, default=_not_present):
         for k in self._gen_keys(ink):
             try:
-                return self._d.get(k)
+                return self._d[k]
             except KeyError:
                 pass
         if default == _not_present:
index 3481702c21e256d5774b2c681443e42a1021f783..a42068044379138bdcf2f92bed97703ec1a0a1a4 100644 (file)
@@ -19,7 +19,7 @@ from email.utils import make_msgid
 from six import binary_type, text_type, PY3, iteritems
 
 from .fixed_offset import FixedOffset
-from .imapclient import IMAPClient, DELETED, RECENT, to_unicode, to_bytes, normalise_untagged_responses
+from .imapclient import IMAPClient, DELETED, RECENT, to_unicode, to_bytes, _dict_bytes_normaliser
 from .response_types import Envelope, Address
 from .test.util import unittest
 from .config import parse_config_file, create_client_from_config
@@ -246,12 +246,12 @@ class TestGeneral(_TestBase):
 
     def test_select_read_only(self):
         self.append_msg(SIMPLE_MESSAGE)
-        untagged = normalise_untagged_responses(self.client._imap.untagged_responses)
+        untagged = _dict_bytes_normaliser(self.client._imap.untagged_responses)
         self.assertNotIn(b'READ-ONLY', untagged)
 
         resp = self.client.select_folder(self.base_folder, readonly=True)
 
-        untagged = normalise_untagged_responses(self.client._imap.untagged_responses)
+        untagged = _dict_bytes_normaliser(self.client._imap.untagged_responses)
         self.assertIn(b'READ-ONLY', untagged)
         self.assertEqual(resp[b'EXISTS'], 1)
         self.assertIsInstance(resp[b'RECENT'], int)