r80669 - in python/trunk: Lib/test/test_multiprocessing.py Lib/test/test_smtplib.py Misc/NEWS
Author: antoine.pitrou Date: Sat May 1 01:08:48 2010 New Revision: 80669 Log: Issue #8576: Remove use of find_unused_port() in test_smtplib and test_multiprocessing. Patch by Paul Moore. Modified: python/trunk/Lib/test/test_multiprocessing.py python/trunk/Lib/test/test_smtplib.py python/trunk/Misc/NEWS Modified: python/trunk/Lib/test/test_multiprocessing.py ============================================================================== --- python/trunk/Lib/test/test_multiprocessing.py (original) +++ python/trunk/Lib/test/test_multiprocessing.py Sat May 1 01:08:48 2010 @@ -1262,9 +1262,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)) @@ -1274,7 +1274,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/trunk/Lib/test/test_smtplib.py ============================================================================== --- python/trunk/Lib/test/test_smtplib.py (original) +++ python/trunk/Lib/test/test_smtplib.py Sat May 1 01:08:48 2010 @@ -155,8 +155,10 @@ self._threads = test_support.threading_setup() 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) self.thread = threading.Thread(target=debugging_server, args=serv_args) self.thread.start() @@ -392,8 +394,10 @@ self._threads = test_support.threading_setup() 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) self.thread = threading.Thread(target=debugging_server, args=serv_args) self.thread.start() Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat May 1 01:08:48 2010 @@ -134,6 +134,9 @@ Tests ----- +- Issue #8576: Remove use of find_unused_port() in test_smtplib and + test_multiprocessing. Patch by Paul Moore. + - Issue #7449: Fix many tests to support Python compiled without thread support. Patches written by Jerry Seutter.
participants (1)
-
antoine.pitrou