Firstly a belated thanks to everyone who replied to my previous question – I had to put my project on hold for a while, but now I am back with more questions.


My objective is to use twisted to do automated logging in to multiple ssh servers to carry out various tasks.  Currently this is done by spawning a separate ssh executable for each session and controlling it through pexpect, and I would like to replace this with a twisted/conch system.


So far I can create conch “exec” sessions to run a single command/script and return the result, but I would like to be able to create shell sessions and do more interactive work.  Does anyone have any examples of doing this?


The biggest issue I have at the moment is how to do Test Driven Development with conch.  I would like to be able to mock out the server that the ssh client talks to, so that I can keep the unit tests self-contained and keep tight control of both sides of the interaction, e.g. for testing failure scenarios.  I can think of three ways of doing this:


1) write a separate ssh server with conch that provides the desired behaviour, and have that spawned as a separate process by the unit tests.


2) as above, but run the ssh server in the same process as the tests, so they are both firing from the same reactor event loop.  IMHO this is better than (1) since it is more self-contained.


3) stub out the low-level classes of the client so that they are not really talking to a server at all, but simulating the correct behaviour.


The problem with both 1 and 2 is that they require writing test code that is as complex as the code I am testing.  The problem with 3 is that it assumes that I know what the correct low-level behaviour is so that I can mock it out.  At the moment I do not grok twisted in sufficient detail to do that.


How have other people tackled this?  Are there any other options that I am missing, or code I can reuse, or other suggestions or advice?



Dave Kirby
Senior Software Engineer
T: +44 20 7368 7330 | F: +44 20 7352 4922
E: | W:


This email and any attachment may contain confidential, privileged information for the sole use of the intended recipient. If you are not the intended recipient, do not disclose, reproduce, disseminate or otherwise use this communication. If you received this communication in error, please immediately notify the sender via email and delete the communication from your system. Company information : Tideway Systems Ltd, Registered Office: Anchor House, 15-19 Britten Street, London, SW3 3TY. Registered in England & Wales Reg. Reg. No: 4598072 VAT No: 805 5153 50