def test_connect(self):
"""
This test performs a TCP connection to the remote host on the
specified port.
The report will contains the string 'success' if the test has
succeeded, or the reason for the failure if it has failed.
"""
def connectionSuccess(protocol):
protocol.transport.loseConnection()
log.debug("Got a connection to %s" % self.input)
self.report["connection"] = 'success'
def connectionFailed(failure):
self.report['connection'] = handleAllFailures(failure)
from twisted.internet import reactor
point = TCP4ClientEndpoint(reactor, self.host, int(self.port))
d = point.connect(TCPFactory())
d.addCallback(connectionSuccess)
d.addErrback(connectionFailed)
return d
评论列表
文章目录