Ok, here goes : The test code : from twisted.trial import unittest from twisted.internet import defer, protocol, reactor class TestAccountStatus(unittest.TestCase): def setUp(self): ssh_server = Server() self.server = reactor.listenTCP(ssh_server.port, ssh_server.application(), interface=ssh_server.interface) return self.server def tearDown(self): server, self.server = self.server,None return server.stopListening() def test_1(self): def got_data(data): self.assertEquals(data,"a") d = protocol.ClientCreator(reactor, SimpleTransport).connectTCP('localhost', self.server.getHost().port) d.addCallback(got_data) return d
The client code : from twisted.conch.ssh import transport, userauth, connection, common, keys, channel from twisted.internet import defer, protocol, reactor class SimpleTransport(transport.SSHClientTransport): def verifyHostKey(self, hostKey, fingerprint): print 'host key fingerprint: %s' % fingerprint return defer.succeed(1) def connectionSecure(self): self.requestService( SimpleUserAuth('webchick', SimpleConnection())) class SimpleUserAuth(userauth.SSHUserAuthClient): def getPassword(self): print "Get Password called" return defer.succeed("Thai1mil3ahb") When I run the test I expect : tests TestAccountStatus test_1 ... Get Password called followed by some errors , but atleast this much should be printed if the client code is being called properly. Instead I get: [FAIL]: tests.TestAccountStatus.test_1 Traceback (most recent call last): File "tests.py", line 92, in got_data self.assertEquals(data,"a") twisted.trial.unittest.FailTest: not equal: a = <tests.SimpleTransport instance at 0x1024aa128> b = 'a' Instead of running the client the deferred is just returning an instance of the Client Transport used by me (SimpleTransport). Any ideas why this is happening? Is this becuse I'm not using a ClientFactory or am I using the deferred all wrong?
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python