summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_socket.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2010-01-03 01:29:44 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2010-01-03 01:29:44 (GMT)
commit79a3eb1058057185cb901b0f5f67fea05494e1fb (patch)
tree09456d423e27dfe76cf46079f944ae877f16e492 /Lib/test/test_socket.py
parent7f8ebdbad54015074c71786abbfa7ea74fe69c56 (diff)
downloadcpython-79a3eb1058057185cb901b0f5f67fea05494e1fb.zip
cpython-79a3eb1058057185cb901b0f5f67fea05494e1fb.tar.gz
cpython-79a3eb1058057185cb901b0f5f67fea05494e1fb.tar.bz2
Adds an optional source_address parameter to socket.create_connection().
For use by issue3972.
Diffstat (limited to 'Lib/test/test_socket.py')
-rw-r--r--Lib/test/test_socket.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 472f403..055af67 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -995,7 +995,7 @@ class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):
ThreadableTest.__init__(self)
def clientSetUp(self):
- pass
+ self.source_port = test_support.find_unused_port()
def clientTearDown(self):
self.cli.close()
@@ -1010,6 +1010,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