[Python-checkins] r87683 - python/branches/py3k/Lib/test/test_xmlrpc.py
victor.stinner
python-checkins at python.org
Mon Jan 3 15:30:44 CET 2011
Author: victor.stinner
Date: Mon Jan 3 15:30:44 2011
New Revision: 87683
Log:
test_xmlrpc: close the transport when done
Fix a ResourceWarning(unclosed socket). Patch written by Nadeem Vawda.
Modified:
python/branches/py3k/Lib/test/test_xmlrpc.py
Modified: python/branches/py3k/Lib/test/test_xmlrpc.py
==============================================================================
--- python/branches/py3k/Lib/test/test_xmlrpc.py (original)
+++ python/branches/py3k/Lib/test/test_xmlrpc.py Mon Jan 3 15:30:44 2011
@@ -629,6 +629,7 @@
self.assertEqual(p.pow(6,8), 6**8)
self.assertEqual(p.pow(6,8), 6**8)
self.assertEqual(p.pow(6,8), 6**8)
+ p("close")()
#they should have all been handled by a single request handler
self.assertEqual(len(self.RequestHandler.myRequests), 1)
@@ -637,6 +638,7 @@
#due to thread scheduling)
self.assertGreaterEqual(len(self.RequestHandler.myRequests[-1]), 2)
+
#test special attribute access on the serverproxy, through the __call__
#function.
class KeepaliveServerTestCase2(BaseKeepaliveServerTestCase):
@@ -653,6 +655,7 @@
self.assertEqual(p.pow(6,8), 6**8)
self.assertEqual(p.pow(6,8), 6**8)
self.assertEqual(p.pow(6,8), 6**8)
+ p("close")()
#they should have all been two request handlers, each having logged at least
#two complete requests
@@ -660,12 +663,14 @@
self.assertGreaterEqual(len(self.RequestHandler.myRequests[-1]), 2)
self.assertGreaterEqual(len(self.RequestHandler.myRequests[-2]), 2)
+
def test_transport(self):
p = xmlrpclib.ServerProxy(URL)
#do some requests with close.
self.assertEqual(p.pow(6,8), 6**8)
p("transport").close() #same as above, really.
self.assertEqual(p.pow(6,8), 6**8)
+ p("close")()
self.assertEqual(len(self.RequestHandler.myRequests), 2)
#A test case that verifies that gzip encoding works in both directions
@@ -709,6 +714,7 @@
self.assertEqual(p.pow(6,8), 6**8)
b = self.RequestHandler.content_length
self.assertTrue(a>b)
+ p("close")()
def test_bad_gzip_request(self):
t = self.Transport()
@@ -719,6 +725,7 @@
re.compile(r"\b400\b"))
with cm:
p.pow(6, 8)
+ p("close")()
def test_gsip_response(self):
t = self.Transport()
@@ -729,6 +736,7 @@
a = t.response_length
self.requestHandler.encode_threshold = 0 #always encode
self.assertEqual(p.pow(6,8), 6**8)
+ p("close")()
b = t.response_length
self.requestHandler.encode_threshold = old
self.assertTrue(a>b)
More information about the Python-checkins
mailing list