コード例 #1
0
ファイル: test_flow.py プロジェクト: fxia22/ASM_xf
 def testProtocol(self):
     from twisted.protocols import loopback
     server = flow.Protocol()
     server.controller = echoServer
     client = flow.makeProtocol(echoClient)()
     client.factory = protocol.ClientFactory()
     client.factory.d = defer.Deferred()
     loopback.loopback(server, client)
     self.assertEquals('testing', unittest.deferredResult(client.factory.d))
コード例 #2
0
ファイル: test_flow.py プロジェクト: emragins/tribal
 def testProtocol(self):
     from twisted.protocols import loopback
     server = flow.Protocol()
     server.controller = echoServer
     client = flow.makeProtocol(echoClient)()
     client.factory = protocol.ClientFactory()
     client.factory.d = defer.Deferred()
     d2 = loopback.loopbackAsync(server, client)
     client.factory.d.addCallback(self.assertEquals, 'testing')
     return defer.gatherResults([client.factory.d, d2])
コード例 #3
0
ファイル: test_flow.py プロジェクト: fxia22/ASM_xf
 def testProtocolLocalhost(self):
     PORT = 8392
     server = protocol.ServerFactory()
     server.protocol = flow.Protocol
     server.protocol.controller = echoServer
     reactor.listenTCP(PORT,server)
     client = protocol.ClientFactory()
     client.protocol = flow.makeProtocol(echoClient)
     client.d = defer.Deferred()
     reactor.connectTCP("localhost", PORT, client)
     self.assertEquals('testing', unittest.deferredResult(client.d))
コード例 #4
0
ファイル: test_flow.py プロジェクト: emragins/tribal
 def testProtocolLocalhost(self):
     # this fails if parallel tests are run on the same box
     server = protocol.ServerFactory()
     server.protocol = flow.Protocol
     server.protocol.controller = echoServer
     port = reactor.listenTCP(0, server)
     client = protocol.ClientFactory()
     client.protocol = flow.makeProtocol(echoClient)
     client.d = defer.Deferred()
     reactor.connectTCP("127.0.0.1", port.getHost().port, client)
     client.d.addCallback(self.assertEquals, 'testing')
     client.d.addBoth(lambda x :
                      client.protocol.transport.loseConnection())
     client.d.addBoth(lambda x :
                      defer.maybeDeferred(port.stopListening))
     return client.d