]> granicus.if.org Git - python/commitdiff
issue #7728: test_timeout was using a hardcoded port, which was
authorR. David Murray <rdmurray@bitdance.com>
Sat, 6 Feb 2010 04:27:21 +0000 (04:27 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Sat, 6 Feb 2010 04:27:21 +0000 (04:27 +0000)
causing buildbot failures.  Changed to use test_support.bind_port.
Patch by Florent Xicluna.

Lib/test/test_timeout.py
Misc/NEWS

index 04cfbe7acef6d880f17022dccfe83cdbbbc9d665..5f19af257a5af95831fb9dad64c14689acfc04b3 100644 (file)
@@ -101,7 +101,7 @@ class TimeoutTestCase(unittest.TestCase):
     def setUp(self):
         self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         self.addr_remote = ('www.python.org.', 80)
-        self.addr_local  = ('127.0.0.1', 25339)
+        self.localhost = '127.0.0.1'
 
     def tearDown(self):
         self.sock.close()
@@ -146,7 +146,8 @@ class TimeoutTestCase(unittest.TestCase):
         # Test accept() timeout
         _timeout = 2
         self.sock.settimeout(_timeout)
-        self.sock.bind(self.addr_local)
+        # Prevent "Address already in use" socket exceptions
+        test_support.bind_port(self.sock, self.localhost)
         self.sock.listen(5)
 
         _t1 = time.time()
@@ -163,7 +164,8 @@ class TimeoutTestCase(unittest.TestCase):
         _timeout = 2
         self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
         self.sock.settimeout(_timeout)
-        self.sock.bind(self.addr_local)
+        # Prevent "Address already in use" socket exceptions
+        test_support.bind_port(self.sock, self.localhost)
 
         _t1 = time.time()
         self.assertRaises(socket.error, self.sock.recvfrom, 8192)
index c1c1f88d1f20cfef972c1949bd72449b6c6ab905..c9beea9da42a4c829dfe87ae5b00b99c9dba42ea 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -150,6 +150,14 @@ Tools/Demos
   added to the `Tools/` directory.  They were previously living in the
   sandbox.
 
+
+Tests
+-----
+
+- issue #7728: test_timeout was changed to use test_support.bind_port
+  instead of a hard coded port.
+
+
 Documentation
 -------------