'L{IReactorTCP.listenTCP} raises L{error.CannotListenError} if the
address to listen on is already in use.'

def test_cannotBind(self):

    f = MyServerFactory()
    p1 = reactor.listenTCP(0, f, interface='127.0.0.1')
    self.addCleanup(p1.stopListening)
    n = p1.getHost().port
    dest = p1.getHost()
    self.assertEqual(dest.type, 'TCP')
    self.assertEqual(dest.host, '127.0.0.1')
    self.assertEqual(dest.port, n)
    self.assertRaises(error.CannotListenError, reactor.listenTCP, n, f, interface='127.0.0.1')
