Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b4e4c925
Commit
b4e4c925
authored
Oct 17, 2012
by
Trent Nelson
Browse files
Options
Browse Files
Download
Plain Diff
Issue #16257: make test_create_connection() handle ENETUNREACH.
parents
9a537a6a
016884cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletion
+20
-1
Lib/test/test_socket.py
Lib/test/test_socket.py
+20
-1
No files found.
Lib/test/test_socket.py
View file @
b4e4c925
...
...
@@ -4109,7 +4109,26 @@ class NetworkConnectionNoServer(unittest.TestCase):
port
=
support
.
find_unused_port
()
with
self
.
assertRaises
(
socket
.
error
)
as
cm
:
socket
.
create_connection
((
HOST
,
port
))
self
.
assertEqual
(
cm
.
exception
.
errno
,
errno
.
ECONNREFUSED
)
# Issue #16257: create_connection() calls getaddrinfo() against
# 'localhost'. This may result in an IPV6 addr being returned
# as well as an IPV4 one:
# >>> socket.getaddrinfo('localhost', port, 0, SOCK_STREAM)
# >>> [(2, 2, 0, '', ('127.0.0.1', 41230)),
# (26, 2, 0, '', ('::1', 41230, 0, 0))]
#
# create_connection() enumerates through all the addresses returned
# and if it doesn't successfully bind to any of them, it propagates
# the last exception it encountered.
#
# On Solaris, ENETUNREACH is returned in this circumstance instead
# of ECONNREFUSED. So, if that errno exists, add it to our list of
# expected errnos.
expected_errnos
=
[
errno
.
ECONNREFUSED
,
]
if
hasattr
(
errno
,
'ENETUNREACH'
):
expected_errnos
.
append
(
errno
.
ENETUNREACH
)
self
.
assertIn
(
cm
.
exception
.
errno
,
expected_errnos
)
def
test_create_connection_timeout
(
self
):
# Issue #9792: create_connection() should not recast timeout errors
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment