From: Kristján Valur Jónsson Date: Sat, 11 Jul 2009 08:44:43 +0000 (+0000) Subject: http://bugs.python.org/issue6460 X-Git-Tag: v2.7a1~802 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ef6007c1ae72f9d0d3607c381b99022b86c92fe9;p=python 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. --- diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py index ff0dec9d7a..92b5fe8fb7 100644 --- a/Lib/test/test_xmlrpc.py +++ b/Lib/test/test_xmlrpc.py @@ -541,11 +541,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)