mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
Merged revisions 77263-77264 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r77263 | gregory.p.smith | 2010-01-02 17:29:44 -0800 (Sat, 02 Jan 2010) | 4 lines Adds an optional source_address parameter to socket.create_connection(). For use by issue3972. ........ r77264 | gregory.p.smith | 2010-01-02 18:06:07 -0800 (Sat, 02 Jan 2010) | 5 lines issue3972: HTTPConnection and HTTPSConnection now support a source_address parameter. Also cleans up an annotation in the socket documentation. ........
This commit is contained in:
parent
91ae4a1404
commit
b4066374db
7 changed files with 89 additions and 14 deletions
|
@ -993,7 +993,7 @@ class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):
|
|||
ThreadableTest.__init__(self)
|
||||
|
||||
def clientSetUp(self):
|
||||
pass
|
||||
self.source_port = support.find_unused_port()
|
||||
|
||||
def clientTearDown(self):
|
||||
self.cli.close()
|
||||
|
@ -1008,6 +1008,19 @@ class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):
|
|||
self.cli = socket.create_connection((HOST, self.port), timeout=30)
|
||||
self.assertEqual(self.cli.family, 2)
|
||||
|
||||
testSourcePort = _justAccept
|
||||
def _testSourcePort(self):
|
||||
self.cli = socket.create_connection((HOST, self.port), timeout=30,
|
||||
source_address=('', self.source_port))
|
||||
self.assertEqual(self.cli.getsockname()[1], self.source_port)
|
||||
|
||||
testSourceAddress = _justAccept
|
||||
def _testSourceAddress(self):
|
||||
self.cli = socket.create_connection(
|
||||
(HOST, self.port), 30, ('127.0.0.1', self.source_port))
|
||||
self.assertEqual(self.cli.getsockname(),
|
||||
('127.0.0.1', self.source_port))
|
||||
|
||||
testTimeoutDefault = _justAccept
|
||||
def _testTimeoutDefault(self):
|
||||
# passing no explicit timeout uses socket's global default
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue