[Python-checkins] cpython: Issue #11748: try to fix sporadic failures in test_ftplib

antoine.pitrou python-checkins at python.org
Sun Apr 3 18:29:49 CEST 2011


http://hg.python.org/cpython/rev/8a2d848244a2
changeset:   69116:8a2d848244a2
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Sun Apr 03 18:29:45 2011 +0200
summary:
  Issue #11748: try to fix sporadic failures in test_ftplib

files:
  Lib/test/test_ftplib.py |  22 ++++++++++++++++------
  1 files changed, 16 insertions(+), 6 deletions(-)


diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py
--- a/Lib/test/test_ftplib.py
+++ b/Lib/test/test_ftplib.py
@@ -611,16 +611,26 @@
     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')

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list