diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2018-08-07 05:12:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-07 05:12:18 +0300 |
commit | e4dcbbd7f4ac18d01c0ec85f64ae98b8281ed403 (patch) | |
tree | c1d8a7e7689aeb7add213b4f289161dbfdff2c81 /Lib/test/test_imaplib.py | |
parent | 3c1b590472d567e22a607ba31271865cd90c8e9b (diff) | |
download | cpython-git-e4dcbbd7f4ac18d01c0ec85f64ae98b8281ed403.tar.gz |
bpo-18540: Fix EAI_NONAME in imaplib.IMAP4*() (GH-8634)
Diffstat (limited to 'Lib/test/test_imaplib.py')
-rw-r--r-- | Lib/test/test_imaplib.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py index f16bacd000..a0b598d0c7 100644 --- a/Lib/test/test_imaplib.py +++ b/Lib/test/test_imaplib.py @@ -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): |