'Calling L{IConnector.connect} in C{Factory.clientConnectionLost} causes
a new connection attempt to be made.'

def test_reconnect(self):

    serverFactory = ClosingFactory()
    reactor = self.buildReactor()
    tcpPort = reactor.listenTCP(0, serverFactory, interface=self.interface)
    serverFactory.port = tcpPort
    portNumber = tcpPort.getHost().port
    clientFactory = MyClientFactory()
    def clientConnectionLost(connector, reason):
        connector.connect()
    clientFactory.clientConnectionLost = clientConnectionLost
    reactor.connectTCP(self.interface, portNumber, clientFactory)
    protocolMadeAndClosed = []
    def reconnectFailed(ignored):
        p = clientFactory.protocol
        protocolMadeAndClosed.append((p.made, p.closed))
        reactor.stop()
    clientFactory.failDeferred.addCallback(reconnectFailed)
    self.runReactor(reactor)
    clientFactory.reason.trap(ConnectionRefusedError)
    self.assertEqual(protocolMadeAndClosed, [(1, 1)])
