]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Added a "shutdown" method.
authorMenno Smits <menno@freshfoo.com>
Tue, 1 Sep 2015 03:30:42 +0000 (15:30 +1200)
committerMenno Smits <menno@freshfoo.com>
Tue, 1 Sep 2015 03:30:42 +0000 (15:30 +1200)
Allows closing of the underlying socket.

Closes #173.

NEWS.rst
imapclient/imapclient.py
imapclient/test/test_imapclient.py

index f9a54177339000031a6728c5180c2e65aea29bd2..096c736449c4a5a8804047e6fdf479a588dba3f2 100644 (file)
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -144,6 +144,9 @@ Other
     easier to use any unicode string as a search string and is safe
     because Gmail supports UTF-8 search criteria.
   * PEP8 compliance fixed (except for some occasional long lines)
+  * Added a "shutdown" method.
+  * The embedded six package has been removed in favour of using an
+    externally installed instance.
 
 ======
  0.13
index 2760584c1571b1b54b68e8cc3a356d70a160a71f..9febb7b1d36cc6f259ab5624ff5e9c2262ea1a21 100644 (file)
@@ -251,6 +251,14 @@ class IMAPClient(object):
         self._check_resp('BYE', 'logout', typ, data)
         return data[0]
 
+    def shutdown(self):
+        """Close the connection to the IMAP server (without logging out)
+
+        In most cases, :py:meth:`.logout` should be used instead of
+        this. The logout method also shutdown down the connection.
+        """
+        self._imap.shutdown()
+
     def id_(self, parameters=None):
         """Issue the ID command, returning a dict of server implementation
         fields.
index e49e59f112339b8bc1792067d9dcfa5019487fea..7cf1aff90f48c78435b6e3e4d9ce76b2fa3cf954 100644 (file)
@@ -599,3 +599,10 @@ class TestRawCommand(IMAPClientTest):
         expected_error = "unexpected response while waiting for continuation response: \(u?'NO', \[u?'go away'\]\)"
         with self.assertRaisesRegex(IMAPClient.AbortError, expected_error):
             self.client._raw_command(b'FOO', [b'\xff'])
+
+
+class TestShutdown(IMAPClientTest):
+
+    def test_shutdown(self):
+        self.client.shutdown()
+        self.client._imap.shutdown.assert_called_once_with()