summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/poplib.py7
-rw-r--r--Lib/test/test_poplib.py16
2 files changed, 23 insertions, 0 deletions
diff --git a/Lib/poplib.py b/Lib/poplib.py
index 4915628..f672390 100644
--- a/Lib/poplib.py
+++ b/Lib/poplib.py
@@ -71,6 +71,7 @@ class POP3:
UIDL [msg] uidl(msg = None)
CAPA capa()
STLS stls()
+ UTF8 utf8()
Raises one exception: 'error_proto'.
@@ -348,6 +349,12 @@ class POP3:
return self._longcmd('UIDL')
+ def utf8(self):
+ """Try to enter UTF-8 mode (see RFC 6856). Returns server response.
+ """
+ return self._shortcmd('UTF8')
+
+
def capa(self):
"""Return server capabilities (RFC 2449) as a dictionary
>>> c=poplib.POP3('localhost')
diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py
index 14a519d..bceeb93 100644
--- a/Lib/test/test_poplib.py
+++ b/Lib/test/test_poplib.py
@@ -44,6 +44,7 @@ line3\r\n\
class DummyPOP3Handler(asynchat.async_chat):
CAPAS = {'UIDL': [], 'IMPLEMENTATION': ['python-testlib-pop-server']}
+ enable_UTF8 = False
def __init__(self, conn):
asynchat.async_chat.__init__(self, conn)
@@ -142,6 +143,11 @@ class DummyPOP3Handler(asynchat.async_chat):
self.push(' '.join(_ln))
self.push('.')
+ def cmd_utf8(self, arg):
+ self.push('+OK I know RFC6856'
+ if self.enable_UTF8
+ else '-ERR What is UTF8?!')
+
if SUPPORTS_SSL:
def cmd_stls(self, arg):
@@ -309,6 +315,16 @@ class TestPOP3Class(TestCase):
self.client.uidl()
self.client.uidl('foo')
+ def test_utf8_raises_if_unsupported(self):
+ self.server.handler.enable_UTF8 = False
+ self.assertRaises(poplib.error_proto, self.client.utf8)
+
+ def test_utf8(self):
+ self.server.handler.enable_UTF8 = True
+ expected = b'+OK I know RFC6856'
+ result = self.client.utf8()
+ self.assertEqual(result, expected)
+
def test_capa(self):
capa = self.client.capa()
self.assertTrue('IMPLEMENTATION' in capa.keys())