diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-11-09 22:57:20 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-11-09 22:57:20 (GMT) |
commit | 7ec819e3a9887ac7bfe857ed6b6fb9018dee40c2 (patch) | |
tree | d514462f525a04b67fd359fe564d21839db412cc | |
parent | de535e8864386bd178da8896a2bd75698077761e (diff) | |
download | cpython-7ec819e3a9887ac7bfe857ed6b6fb9018dee40c2.zip cpython-7ec819e3a9887ac7bfe857ed6b6fb9018dee40c2.tar.gz cpython-7ec819e3a9887ac7bfe857ed6b6fb9018dee40c2.tar.bz2 |
Merged revisions 86380 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r86380 | antoine.pitrou | 2010-11-09 23:55:55 +0100 (mar., 09 nov. 2010) | 4 lines
Fix IMAP.login() to work properly.
Also, add remote tests for imaplib (part of #4471).
........
-rw-r--r-- | Lib/imaplib.py | 6 | ||||
-rw-r--r-- | Lib/test/test_imaplib.py | 46 | ||||
-rw-r--r-- | Misc/NEWS | 2 |
3 files changed, 48 insertions, 6 deletions
diff --git a/Lib/imaplib.py b/Lib/imaplib.py index 9b0fd3b..1b37546 100644 --- a/Lib/imaplib.py +++ b/Lib/imaplib.py @@ -1054,10 +1054,10 @@ class IMAP4: def _quote(self, arg): - arg = arg.replace(b'\\', b'\\\\') - arg = arg.replace(b'"', b'\\"') + arg = arg.replace('\\', '\\\\') + arg = arg.replace('"', '\\"') - return b'"' + arg + b'"' + return '"' + arg + '"' def _simple_command(self, name, *args): diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py index fb5cf82..db07dd5 100644 --- a/Lib/test/test_imaplib.py +++ b/Lib/test/test_imaplib.py @@ -13,7 +13,7 @@ import socketserver import sys import time -from test.support import reap_threads, verbose +from test.support import reap_threads, verbose, transient_internet import unittest try: @@ -195,8 +195,45 @@ class ThreadedNetworkedTestsSSL(BaseThreadedNetworkedTests): imap_class = IMAP4_SSL -def test_main(): +class RemoteIMAPTest(unittest.TestCase): + host = 'cyrus.andrew.cmu.edu' + port = 143 + username = 'anonymous' + password = 'pass' + imap_class = imaplib.IMAP4 + + def setUp(self): + with transient_internet(self.host): + self.server = self.imap_class(self.host, self.port) + + def tearDown(self): + if self.server is not None: + self.server.logout() + + def test_logincapa(self): + self.assertTrue('LOGINDISABLED' in self.server.capabilities) + + def test_anonlogin(self): + self.assertTrue('AUTH=ANONYMOUS' in self.server.capabilities) + rs = self.server.login(self.username, self.password) + self.assertEqual(rs[0], 'OK') + + def test_logout(self): + rs = self.server.logout() + self.assertEqual(rs[0], 'BYE') + +@unittest.skipUnless(ssl, "SSL not available") +class RemoteIMAP_SSLTest(RemoteIMAPTest): + port = 993 + imap_class = IMAP4_SSL + + def test_logincapa(self): + self.assertFalse('LOGINDISABLED' in self.server.capabilities) + self.assertTrue('AUTH=PLAIN' in self.server.capabilities) + + +def test_main(): tests = [TestImaplib] if support.is_resource_enabled('network'): @@ -206,7 +243,10 @@ def test_main(): "keycert.pem") if not os.path.exists(CERTFILE): raise support.TestFailed("Can't read certificate files!") - tests.extend([ThreadedNetworkedTests, ThreadedNetworkedTestsSSL]) + tests.extend([ + ThreadedNetworkedTests, ThreadedNetworkedTestsSSL, + RemoteIMAPTest, RemoteIMAP_SSLTest, + ]) support.run_unittest(*tests) @@ -143,6 +143,8 @@ C-API Library ------- +- Fix IMAP.login() to work properly. + - Issue #10126: Fix distutils' test_build when Python was built with --enable-shared. |