summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ftplib.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-04-03 16:29:45 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-04-03 16:29:45 (GMT)
commit6dca52772b4b979652565442ef247deddacc269f (patch)
tree5a81be514d46244b33d572692c92a380369c182c /Lib/test/test_ftplib.py
parenta7caec74aabed6842e5ea608df431a35987195c0 (diff)
downloadcpython-6dca52772b4b979652565442ef247deddacc269f.zip
cpython-6dca52772b4b979652565442ef247deddacc269f.tar.gz
cpython-6dca52772b4b979652565442ef247deddacc269f.tar.bz2
Issue #11748: try to fix sporadic failures in test_ftplib
Diffstat (limited to 'Lib/test/test_ftplib.py')
-rw-r--r--Lib/test/test_ftplib.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py
index 127b1b9..9edb197 100644
--- a/Lib/test/test_ftplib.py
+++ b/Lib/test/test_ftplib.py
@@ -611,16 +611,26 @@ class TestFTPClass(TestCase):
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()
+ try:
+ self.client.connect(self.server.host, self.server.port,
+ source_address=(HOST, port))
+ self.assertEqual(self.client.sock.getsockname()[1], port)
+ self.client.quit()
+ except IOError as e:
+ if e.errno == errno.EADDRINUSE:
+ self.skipTest("couldn't bind to port %d" % port)
+ raise
def test_source_address_passive_connection(self):
port = support.find_unused_port()
self.client.source_address = (HOST, port)
- with self.client.transfercmd('list') as sock:
- self.assertEqual(sock.getsockname()[1], port)
+ try:
+ with self.client.transfercmd('list') as sock:
+ self.assertEqual(sock.getsockname()[1], port)
+ except IOError as e:
+ if e.errno == errno.EADDRINUSE:
+ self.skipTest("couldn't bind to port %d" % port)
+ raise
def test_parse257(self):
self.assertEqual(ftplib.parse257('257 "/foo/bar"'), '/foo/bar')