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
052d46de
Commit
052d46de
authored
Aug 16, 2013
by
Charles-François Natali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #16463: Fix a transient test_timeout failure.
parent
eadbe2ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
Lib/test/test_timeout.py
Lib/test/test_timeout.py
+16
-3
No files found.
Lib/test/test_timeout.py
View file @
052d46de
"""Unit tests for socket timeout feature."""
import
functools
import
unittest
from
test
import
support
...
...
@@ -11,6 +12,18 @@ import errno
import
socket
@
functools
.
lru_cache
()
def
resolve_address
(
host
,
port
):
"""Resolve an (host, port) to an address.
We must perform name resolution before timeout tests, otherwise it will be
performed by connect().
"""
with
support
.
transient_internet
(
host
):
return
socket
.
getaddrinfo
(
host
,
port
,
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)[
0
][
4
]
class
CreationTestCase
(
unittest
.
TestCase
):
"""Test case for socket.gettimeout() and socket.settimeout()"""
...
...
@@ -132,7 +145,7 @@ class TCPTimeoutTestCase(TimeoutTestCase):
def
setUp
(
self
):
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
addr_remote
=
(
'www.python.org.'
,
80
)
self
.
addr_remote
=
resolve_address
(
'www.python.org.'
,
80
)
def
tearDown
(
self
):
self
.
sock
.
close
()
...
...
@@ -142,7 +155,7 @@ class TCPTimeoutTestCase(TimeoutTestCase):
# to a host that silently drops our packets. We can't simulate this
# from Python because it's a function of the underlying TCP/IP stack.
# So, the following Snakebite host has been defined:
blackhole
=
(
'blackhole.snakebite.net'
,
56666
)
blackhole
=
resolve_address
(
'blackhole.snakebite.net'
,
56666
)
# Blackhole has been configured to silently drop any incoming packets.
# No RSTs (for TCP) or ICMP UNREACH (for UDP/ICMP) will be sent back
...
...
@@ -154,7 +167,7 @@ class TCPTimeoutTestCase(TimeoutTestCase):
# to firewalling or general network configuration. In order to improve
# our confidence in testing the blackhole, a corresponding 'whitehole'
# has also been set up using one port higher:
whitehole
=
(
'whitehole.snakebite.net'
,
56667
)
whitehole
=
resolve_address
(
'whitehole.snakebite.net'
,
56667
)
# This address has been configured to immediately drop any incoming
# packets as well, but it does it respectfully with regards to the
...
...
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