summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ftplib.py
diff options
context:
space:
mode:
authorGiampaolo RodolĂ  <g.rodola@gmail.com>2011-02-28 19:19:51 (GMT)
committerGiampaolo RodolĂ  <g.rodola@gmail.com>2011-02-28 19:19:51 (GMT)
commit396ff060519a8e7cda872df92f70578d3913921a (patch)
tree1658bb534841ab492d3124c5342756ca2834491c /Lib/test/test_ftplib.py
parent8a14a0c88bf5b72da899c9ce9863e14dcd48b9c7 (diff)
downloadcpython-396ff060519a8e7cda872df92f70578d3913921a.zip
cpython-396ff060519a8e7cda872df92f70578d3913921a.tar.gz
cpython-396ff060519a8e7cda872df92f70578d3913921a.tar.bz2
Fix issue 8594: adds a source_address parameter to ftplib module.
Diffstat (limited to 'Lib/test/test_ftplib.py')
-rw-r--r--Lib/test/test_ftplib.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py
index 9d2eab7..5f8a8bd 100644
--- a/Lib/test/test_ftplib.py
+++ b/Lib/test/test_ftplib.py
@@ -608,6 +608,20 @@ class TestFTPClass(TestCase):
self.assertEqual(self.server.handler_instance.last_received_cmd, 'quit')
self.assertFalse(is_client_connected())
+ def test_source_address(self):
+ self.client.quit()
+ port = support.find_unused_port()
+ self.client.connect(self.server.host, self.server.port,
+ source_address=(HOST, port))
+ self.assertEqual(self.client.sock.getsockname()[1], port)
+ self.client.quit()
+
+ def test_source_address_passive_connection(self):
+ port = support.find_unused_port()
+ self.client.source_address = (HOST, port)
+ sock = self.client.transfercmd('list')
+ self.assertEqual(sock.getsockname()[1], port)
+
def test_parse257(self):
self.assertEqual(ftplib.parse257('257 "/foo/bar"'), '/foo/bar')
self.assertEqual(ftplib.parse257('257 "/foo/bar" created'), '/foo/bar')