'If C{connectionLost} is called directory on a port object and that the
server factory raises an exception in C{stopFactory}, the exception is
passed through to the caller.
C{connectionLost} is called by L{reactor.disconnectAll} at shutdown.'

def test_exceptInConnectionLostCall(self):

    serverFactory = MyServerFactory()
    def raiseException():
        raise RuntimeError('An    error')
    serverFactory.stopFactory = raiseException
    port = reactor.listenTCP(0, serverFactory, interface='127.0.0.1')
    self.assertRaises(RuntimeError, port.connectionLost, None)
