Testing twisted protocol

喜你入骨 提交于 2019-12-07 11:55:07

问题


I have a very basic client and server protocols developed using Twisted. Twisted allows to unittest them independently and provides nice testing utils such as the StringTransport for this.

However, let's say I want to test the protocol works fine. For instance, I want to test that when the server receives a certain message, it will reply to the client in some specific way. What is the best way to do that using trial and the utils in Twisted? I am currently launching processes to run them, but then I lose the access to their objects and I need to dump their states in a file to validate the correct behaviour. I don't think this is a clean way to do it. It would be much better to use a StringTransport that simulates a TCP connection from the client to the server. How do twisted developers normally test this?

来源:https://stackoverflow.com/questions/30100752/testing-twisted-protocol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!