'When an endpoint tries to listen on an already listening port, a
C{CannotListenError} failure is errbacked.'

def test_endpointListenFailure(self):

    factory = object()
    exception = error.CannotListenError('', 80, factory)
    mreactor = RaisingMemoryReactor(listenException=exception)
    (ep, ignoredArgs, ignoredDest) = self.createServerEndpoint(mreactor, factory)
    d = ep.listen(object())
    receivedExceptions = []
    def checkFailure(f):
        receivedExceptions.append(f.value)
    d.addErrback(checkFailure)
    self.assertEqual(receivedExceptions, [exception])
