[Python-checkins] r80670 - in python/branches/release26-maint: Lib/test/test_multiprocessing.py Lib/test/test_smtplib.py Misc/NEWS

antoine.pitrou python-checkins at python.org
Sat May 1 01:10:44 CEST 2010


Author: antoine.pitrou
Date: Sat May  1 01:10:44 2010
New Revision: 80670

Log:
Merged revisions 80669 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r80669 | antoine.pitrou | 2010-05-01 01:08:48 +0200 (sam., 01 mai 2010) | 4 lines
  
  Issue #8576: Remove use of find_unused_port() in test_smtplib and
  test_multiprocessing.  Patch by Paul Moore.
........


Modified:
   python/branches/release26-maint/   (props changed)
   python/branches/release26-maint/Lib/test/test_multiprocessing.py
   python/branches/release26-maint/Lib/test/test_smtplib.py
   python/branches/release26-maint/Misc/NEWS

Modified: python/branches/release26-maint/Lib/test/test_multiprocessing.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_multiprocessing.py	(original)
+++ python/branches/release26-maint/Lib/test/test_multiprocessing.py	Sat May  1 01:10:44 2010
@@ -1205,9 +1205,9 @@
 
     def test_rapid_restart(self):
         authkey = os.urandom(32)
-        port = test_support.find_unused_port()
         manager = QueueManager(
-            address=('localhost', port), authkey=authkey, serializer=SERIALIZER)
+            address=('localhost', 0), authkey=authkey, serializer=SERIALIZER)
+        addr = manager.get_server().address
         manager.start()
 
         p = self.Process(target=self._putter, args=(manager.address, authkey))
@@ -1217,7 +1217,7 @@
         del queue
         manager.shutdown()
         manager = QueueManager(
-            address=('localhost', port), authkey=authkey, serializer=SERIALIZER)
+            address=addr, authkey=authkey, serializer=SERIALIZER)
         manager.start()
         manager.shutdown()
 

Modified: python/branches/release26-maint/Lib/test/test_smtplib.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_smtplib.py	(original)
+++ python/branches/release26-maint/Lib/test/test_smtplib.py	Sat May  1 01:10:44 2010
@@ -144,8 +144,10 @@
 
         self.serv_evt = threading.Event()
         self.client_evt = threading.Event()
-        self.port = test_support.find_unused_port()
-        self.serv = smtpd.DebuggingServer((HOST, self.port), ('nowhere', -1))
+        # Pick a random unused port by passing 0 for the port number
+        self.serv = smtpd.DebuggingServer((HOST, 0), ('nowhere', -1))
+        # Keep a note of what port was assigned
+        self.port = self.serv.socket.getsockname()[1]
         serv_args = (self.serv, self.serv_evt, self.client_evt)
         threading.Thread(target=debugging_server, args=serv_args).start()
 
@@ -371,8 +373,10 @@
     def setUp(self):
         self.serv_evt = threading.Event()
         self.client_evt = threading.Event()
-        self.port = test_support.find_unused_port()
-        self.serv = SimSMTPServer((HOST, self.port), ('nowhere', -1))
+        # Pick a random unused port by passing 0 for the port number
+        self.serv = SimSMTPServer((HOST, 0), ('nowhere', -1))
+        # Keep a note of what port was assigned
+        self.port = self.serv.socket.getsockname()[1]
         serv_args = (self.serv, self.serv_evt, self.client_evt)
         threading.Thread(target=debugging_server, args=serv_args).start()
 

Modified: python/branches/release26-maint/Misc/NEWS
==============================================================================
--- python/branches/release26-maint/Misc/NEWS	(original)
+++ python/branches/release26-maint/Misc/NEWS	Sat May  1 01:10:44 2010
@@ -140,6 +140,9 @@
 Tests
 -----
 
+- Issue #8576: Remove use of find_unused_port() in test_smtplib and
+  test_multiprocessing.  Patch by Paul Moore.
+
 - Issue #7027: regrtest.py keeps a reference to the encodings.ascii module as a
   workaround to #7140 bug
 


More information about the Python-checkins mailing list