Twisted protocol testing

I have very simple client and server protocols developed with Twisted

. Twisted allows unittest to do it on its own and provides useful testing utilities for this, such as StringTransport

.

However, let's say I want to check the protocol is working fine. For example, I want to check that when the server receives a certain message, it will respond to the client in a certain way. What's the best way to do this with trial

and utils in Twisted? I am currently running processes to start them, but then I lose access to their objects and I need to reset their states in a file in order to verify that the behavior is correct. I don't think this is a clean way to do it. It would be much better to use StringTransport

one that simulates a TCP connection from client to server. How do twisted devs usually test this?

+2


source to share





All Articles