我只想在setUp和tearDown中为WebSocketClientProtocol
编写一个TestCase,我想我正确设置了服务器。
我想要的只是test client connected to server and server send some message client will receive
就是这样。
以下是我尝试制作的代码,但我不会再从这里开始了
class WebSocketTest(unittest.TestCase):
def setUp(self):
factory = WebSocketServerFactory("ws://localhost:8000")
self.listening_port = listenWS(factory)
self.factory, self.port = factory, port
def tearDown(self):
self.listening_port.stopListening()
def test_client_message(self):
client_factory = TestClientProtocolFactory(
url="ws://127.0.0.1:8000".format(self.port))
connectWS(client_factory)