mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
bpo-18540: Fix EAI_NONAME in imaplib.IMAP4*() (GH-8634)
This commit is contained in:
parent
3c1b590472
commit
e4dcbbd7f4
3 changed files with 22 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
from test import support
|
||||
|
||||
from contextlib import contextmanager
|
||||
import errno
|
||||
import imaplib
|
||||
import os.path
|
||||
import socketserver
|
||||
|
@ -69,6 +70,19 @@ class TestImaplib(unittest.TestCase):
|
|||
for t in self.timevalues():
|
||||
imaplib.Time2Internaldate(t)
|
||||
|
||||
def test_imap4_host_default_value(self):
|
||||
expected_errnos = [
|
||||
# This is the exception that should be raised.
|
||||
errno.ECONNREFUSED,
|
||||
]
|
||||
if hasattr(errno, 'EADDRNOTAVAIL'):
|
||||
# socket.create_connection() fails randomly with
|
||||
# EADDRNOTAVAIL on Travis CI.
|
||||
expected_errnos.append(errno.EADDRNOTAVAIL)
|
||||
with self.assertRaises(OSError) as cm:
|
||||
imaplib.IMAP4()
|
||||
self.assertIn(cm.exception.errno, expected_errnos)
|
||||
|
||||
|
||||
if ssl:
|
||||
class SecureTCPServer(socketserver.TCPServer):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue