mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
bpo-36629: Add support.get_socket_conn_refused_errs() (GH-12834)
Fix test_imap4_host_default_value() of test_imaplib: catch also errno.ENETUNREACH error.
This commit is contained in:
parent
f1464f4d2e
commit
3c7931e514
4 changed files with 21 additions and 16 deletions
|
@ -81,14 +81,8 @@ class TestImaplib(unittest.TestCase):
|
|||
except socket.error:
|
||||
pass
|
||||
|
||||
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)
|
||||
# This is the exception that should be raised.
|
||||
expected_errnos = support.get_socket_conn_refused_errs()
|
||||
with self.assertRaises(OSError) as cm:
|
||||
imaplib.IMAP4()
|
||||
self.assertIn(cm.exception.errno, expected_errnos)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue