def test_server_closes(self):
     addr = self.start_server()
     closeDedicatedServer(addr)
     def fails_with_socket_error():
         time.sleep(self.serverCloseTime)
         RemoteTestCase.createPickleConnection(addr, timeout = 1)
     self.assertRaises(socket.error, fails_with_socket_error)
 def test_server_can_be_closed_locally(self):
     server = SimplePickleServer.SimplePickleServer(('127.0.0.1', 0), \
                     SimplePickleServer.PickleRequestHandler)
     closed = []
     _server_close = server.server_close
     def server_close():
         _server_close()
         closed.append(1)
     server.server_close = server_close
     port = server.server_address[1]
     thread.start_new(server.serve_forever, ())
     closeDedicatedServer(('127.0.0.1', port))
     time.sleep(self.serverCloseTime)
     self.assertEquals(closed, [1], 'the server is closed')
 def tearDown(self):
     for address in self.server_addresses:
         closeDedicatedServer(address)