summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-01-03 14:30:44 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-01-03 14:30:44 (GMT)
commita935e8ffc67bc68092ee30f67e066efaca984a4e (patch)
treeea62425873ba12951d5db694cc07b8e4373465a6 /Lib/test
parent270fe408319ad575092efca0dcdebab9ecdba70c (diff)
downloadcpython-a935e8ffc67bc68092ee30f67e066efaca984a4e.zip
cpython-a935e8ffc67bc68092ee30f67e066efaca984a4e.tar.gz
cpython-a935e8ffc67bc68092ee30f67e066efaca984a4e.tar.bz2
test_xmlrpc: close the transport when done
Fix a ResourceWarning(unclosed socket). Patch written by Nadeem Vawda.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_xmlrpc.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 6117aab..102f892 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -629,6 +629,7 @@ class KeepaliveServerTestCase1(BaseKeepaliveServerTestCase):
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 @@ class KeepaliveServerTestCase1(BaseKeepaliveServerTestCase):
#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 @@ class KeepaliveServerTestCase2(BaseKeepaliveServerTestCase):
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 @@ class KeepaliveServerTestCase2(BaseKeepaliveServerTestCase):
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 @@ class GzipServerTestCase(BaseServerTestCase):
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 @@ class GzipServerTestCase(BaseServerTestCase):
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 @@ class GzipServerTestCase(BaseServerTestCase):
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)