'If the server factory raises an exception in C{stopFactory}, the
deferred returned by L{tcp.Port.stopListening} should fail with the
corresponding error.'

def test_exceptInStop(self):

    serverFactory = MyServerFactory()
    def raiseException():
        raise RuntimeError('An    error')
    serverFactory.stopFactory = raiseException
    port = reactor.listenTCP(0, serverFactory, interface='127.0.0.1')
    return self.assertFailure(port.stopListening(), RuntimeError)
