From: Antoine Pitrou Date: Sun, 3 Apr 2011 16:29:45 +0000 (+0200) Subject: Issue #11748: try to fix sporadic failures in test_ftplib X-Git-Tag: v3.3.0a1~2688 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6dca52772b4b979652565442ef247deddacc269f;p=thirdparty%2FPython%2Fcpython.git Issue #11748: try to fix sporadic failures in test_ftplib --- diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py index 127b1b956f34..9edb19706b6b 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')