1

我只想WebSocketClientProtocol在 setUp 和 tearDown 中编写一个 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)
4

0 回答 0