summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-10-02 21:37:41 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-10-02 21:37:41 (GMT)
commit22cd02165679e615d5d4d0d797991f9c5fd439d4 (patch)
treec8ccb8fec5cb45b2e63d48312e06682ec21ebbee /Lib/test
parenta8726c4d96e5b56013e5c1e6c6fd25a578eb4ae4 (diff)
parent86aed0bbc64a8dbaaff8517eb2db757a7a17a7ce (diff)
downloadcpython-22cd02165679e615d5d4d0d797991f9c5fd439d4.zip
cpython-22cd02165679e615d5d4d0d797991f9c5fd439d4.tar.gz
cpython-22cd02165679e615d5d4d0d797991f9c5fd439d4.tar.bz2
Fix ResourceWarnings in the TIPC socket tests.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_socket.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 39bb10c..06b9a0d 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -3999,10 +3999,12 @@ def isTipcAvailable():
print("TIPC module is not loaded, please 'sudo modprobe tipc'")
return False
-class TIPCTest (unittest.TestCase):
+class TIPCTest(unittest.TestCase):
def testRDM(self):
srv = socket.socket(socket.AF_TIPC, socket.SOCK_RDM)
cli = socket.socket(socket.AF_TIPC, socket.SOCK_RDM)
+ self.addCleanup(srv.close)
+ self.addCleanup(cli.close)
srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
srvaddr = (socket.TIPC_ADDR_NAMESEQ, TIPC_STYPE,
@@ -4019,13 +4021,14 @@ class TIPCTest (unittest.TestCase):
self.assertEqual(msg, MSG)
-class TIPCThreadableTest (unittest.TestCase, ThreadableTest):
+class TIPCThreadableTest(unittest.TestCase, ThreadableTest):
def __init__(self, methodName = 'runTest'):
unittest.TestCase.__init__(self, methodName = methodName)
ThreadableTest.__init__(self)
def setUp(self):
self.srv = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM)
+ self.addCleanup(self.srv.close)
self.srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
srvaddr = (socket.TIPC_ADDR_NAMESEQ, TIPC_STYPE,
TIPC_LOWER, TIPC_UPPER)
@@ -4033,6 +4036,7 @@ class TIPCThreadableTest (unittest.TestCase, ThreadableTest):
self.srv.listen(5)
self.serverExplicitReady()
self.conn, self.connaddr = self.srv.accept()
+ self.addCleanup(self.conn.close)
def clientSetUp(self):
# The is a hittable race between serverExplicitReady() and the
@@ -4040,6 +4044,7 @@ class TIPCThreadableTest (unittest.TestCase, ThreadableTest):
# we could get an exception
time.sleep(0.1)
self.cli = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM)
+ self.addCleanup(self.cli.close)
addr = (socket.TIPC_ADDR_NAME, TIPC_STYPE,
TIPC_LOWER + int((TIPC_UPPER - TIPC_LOWER) / 2), 0)
self.cli.connect(addr)