mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
#21804: Add RFC 6856 (UTF8) support to poplib.
Patch by Milan Oberkirch.
This commit is contained in:
parent
8eb1f077c2
commit
b8cd3e4e30
5 changed files with 41 additions and 0 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue