]> granicus.if.org Git - python/commitdiff
merging revision 73932 from trunk:
authorKristján Valur Jónsson <kristjan@ccpgames.com>
Sat, 11 Jul 2009 21:57:16 +0000 (21:57 +0000)
committerKristján Valur Jónsson <kristjan@ccpgames.com>
Sat, 11 Jul 2009 21:57:16 +0000 (21:57 +0000)
http://bugs.python.org/issue6460
Need to be careful with thread switching when testing the xmlrpc server.  The server thread may not have updated stats when the client thread tests them.

Lib/test/test_xmlrpc.py

index 100a93cfcc75ed65be7d88210a18f6a93aac0671..846162815575fbcd77097724a01ff4a3b4559dc9 100644 (file)
@@ -507,11 +507,17 @@ class KeepaliveServerTestCase(BaseServerTestCase):
 
     def test_two(self):
         p = xmlrpclib.ServerProxy(URL)
+        #do three requests.
         self.assertEqual(p.pow(6,8), 6**8)
         self.assertEqual(p.pow(6,8), 6**8)
+        self.assertEqual(p.pow(6,8), 6**8)
+
+        #they should have all been handled by a single request handler
         self.assertEqual(len(self.RequestHandler.myRequests), 1)
-        #we may or may not catch the final "append" with the empty line
-        self.assertTrue(len(self.RequestHandler.myRequests[-1]) >= 2)
+
+        #check that we did at least two (the third may be pending append
+        #due to thread scheduling)
+        self.assertGreaterEqual(len(self.RequestHandler.myRequests[-1]), 2)
 
 #A test case that verifies that gzip encoding works in both directions
 #(for a request and the response)