Replace SocketTCPTest, etc. with classes from the sendmsg patch Index: Lib/test/test_socket.py =================================================================== --- Lib/test/test_socket.py.orig +++ Lib/test/test_socket.py @@ -59,27 +59,6 @@ # Size in bytes of the int type SIZEOF_INT = array.array("i").itemsize -class SocketTCPTest(unittest.TestCase): - - def setUp(self): - self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.port = support.bind_port(self.serv) - self.serv.listen(1) - - def tearDown(self): - self.serv.close() - self.serv = None - -class SocketUDPTest(unittest.TestCase): - - def setUp(self): - self.serv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - self.port = support.bind_port(self.serv) - - def tearDown(self): - self.serv.close() - self.serv = None - class ThreadSafeCleanupTestCase(unittest.TestCase): """Subclass of unittest.TestCase with thread-safe cleanup methods. @@ -199,67 +178,6 @@ self.done.set() thread.exit() -class ThreadedTCPSocketTest(SocketTCPTest, ThreadableTest): - - def __init__(self, methodName='runTest'): - SocketTCPTest.__init__(self, methodName=methodName) - ThreadableTest.__init__(self) - - def clientSetUp(self): - self.cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - - def clientTearDown(self): - self.cli.close() - self.cli = None - ThreadableTest.clientTearDown(self) - -class ThreadedUDPSocketTest(SocketUDPTest, ThreadableTest): - - def __init__(self, methodName='runTest'): - SocketUDPTest.__init__(self, methodName=methodName) - ThreadableTest.__init__(self) - - def clientSetUp(self): - self.cli = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - - def clientTearDown(self): - self.cli.close() - self.cli = None - ThreadableTest.clientTearDown(self) - -class SocketConnectedTest(ThreadedTCPSocketTest): - """Socket tests for client-server connection. - - self.cli_conn is a client socket connected to the server. The - setUp() method guarantees that it is connected to the server. - """ - - def __init__(self, methodName='runTest'): - ThreadedTCPSocketTest.__init__(self, methodName=methodName) - - def setUp(self): - ThreadedTCPSocketTest.setUp(self) - # Indicate explicitly we're ready for the client thread to - # proceed and then perform the blocking call to accept - self.serverExplicitReady() - conn, addr = self.serv.accept() - self.cli_conn = conn - - def tearDown(self): - self.cli_conn.close() - self.cli_conn = None - ThreadedTCPSocketTest.tearDown(self) - - def clientSetUp(self): - ThreadedTCPSocketTest.clientSetUp(self) - self.cli.connect((HOST, self.port)) - self.serv_conn = self.cli - - def clientTearDown(self): - self.serv_conn.close() - self.serv_conn = None - ThreadedTCPSocketTest.clientTearDown(self) - class SocketPairTest(unittest.TestCase, ThreadableTest): def __init__(self, methodName='runTest'): @@ -456,6 +374,25 @@ return socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) +# Replacements for original test classes. + +class SocketUDPTest(UDPTestBase): + # Can delete this - it's not used at the time of writing. + pass + +class ThreadedUDPSocketTest(ThreadedSocketTestMixin, UDPTestBase): + pass + +class SocketTCPTest(SocketListeningTestMixin, TCPTestBase): + pass + +class ThreadedTCPSocketTest(ThreadedSocketTestMixin, SocketTCPTest): + pass + +class SocketConnectedTest(ConnectedStreamTestMixin, TCPTestBase): + pass + + # Test-skipping decorators for use with ThreadableTest. def skipWithClientIf(condition, reason):