'The factory passed to L{IReactorTCP.connectTCP} should be started when
the connection attempt starts and stopped when it is over.'

def test_clientStartStop(self):

    f = ClosingFactory()
    p = reactor.listenTCP(0, f, interface='127.0.0.1')
    f.port = p
    self.addCleanup(f.cleanUp)
    portNumber = p.getHost().port
    factory = ClientStartStopFactory()
    reactor.connectTCP('127.0.0.1', portNumber, factory)
    self.assertTrue(factory.started)
    return loopUntil((lambda : factory.stopped))
