[Python-checkins] r50485 - in sandbox/trunk/pdb: mconnection.py test/test_mconnection.py

matt.fleming python-checkins at python.org
Fri Jul 7 22:28:03 CEST 2006


Author: matt.fleming
Date: Fri Jul  7 22:28:02 2006
New Revision: 50485

Modified:
   sandbox/trunk/pdb/mconnection.py
   sandbox/trunk/pdb/test/test_mconnection.py
Log:
Make sure we dont reuse the server address.. tests passed on Linux but were hanging on Windows. Explicitly tell the test not to reuse addr.

Modified: sandbox/trunk/pdb/mconnection.py
==============================================================================
--- sandbox/trunk/pdb/mconnection.py	(original)
+++ sandbox/trunk/pdb/mconnection.py	Fri Jul  7 22:28:02 2006
@@ -138,7 +138,7 @@
             line = self.input.recv(bufsize)
         except socket.error, e:
             raise ReadError, e[1]
-        if len(line) == 0:
+        if not line:
             raise ReadError, 'Connection closed'
         if line[-1] != '\n': line += '\n'
         return line
@@ -187,7 +187,7 @@
             line = self._sock.recv(bufsize)
         except socket.error, e:
             raise ReadError, e[1]
-        if len(line) == 0:
+        if not line:
             raise ReadError, 'Connection closed'
         return line
 

Modified: sandbox/trunk/pdb/test/test_mconnection.py
==============================================================================
--- sandbox/trunk/pdb/test/test_mconnection.py	(original)
+++ sandbox/trunk/pdb/test/test_mconnection.py	Fri Jul  7 22:28:02 2006
@@ -78,9 +78,9 @@
         thread.start_new_thread(repeatedConnect, (self.client, __addr__))
         self.server.connect(__addr__)
 
-        # Set up second server on same port
+        # Set up second server on same port and do not reuse the addr
         s = MConnectionServerTCP()
-        self.assertRaises(ConnectionFailed, s.connect, __addr__)
+        self.assertRaises(ConnectionFailed, s.connect, __addr__, False)
 
     def testInvalidServerAddress(self):
         """(tcp) Connect to an invalid hostname. """
@@ -102,8 +102,12 @@
 
         while self.server._sock == None:
             pass
-
+            
         repeatedConnect(self.client, __addr__)
+
+        # Wait to make _absolutely_ sure that the client has connected
+        while self.server.output == None:
+            pass
         self.client.disconnect()
         self.assertRaises(ReadError, self.server.readline)
 


More information about the Python-checkins mailing list