def test_publish_fail(self):
        def fakeSend(factory):
            raise Exception("ohnoz!")

        def checkPublish(error):
            self.assertEqual(str(error), "exceptions.Exception: ohnoz!")

        def checkListen(server):
            self.assertEqual(self.factory.testMessage, "")
            failure = server.publish("a really special message")
            d = self.assertFailure(failure, exceptions.PublishingError)
            d.addCallback(checkPublish)

        s = ZmqPubConnection(ZmqEndpoint(ZmqEndpointType.bind, "inproc://#1"))
        self.patch(s, 'send', fakeSend)
        d = s.listen(self.factory)
        d.addCallback(checkListen)
        return d
    def test_publish_success(self):
        def fakeSend(message):
            self.factory.testMessage = message

        def checkPublish(server):
            expected = "\x00a really special message"
            self.assertEqual(self.factory.testMessage, expected)

        def checkListen(server):
            self.assertEqual(self.factory.testMessage, "")
            d = server.publish("a really special message")
            d.addCallback(checkPublish)

        s = ZmqPubConnection(ZmqEndpoint(ZmqEndpointType.bind, "inproc://#1"))
        self.patch(s, 'send', fakeSend)
        d = s.listen(self.factory)
        d.addCallback(checkListen)
        return d
    def test_publish_fail(self):

        def fakeSend(factory):
            raise Exception("ohnoz!")

        def checkPublish(error):
            self.assertEqual(str(error), "exceptions.Exception: ohnoz!")

        def checkListen(server):
            self.assertEqual(self.factory.testMessage, "")
            failure = server.publish("a really special message")
            d = self.assertFailure(failure, exceptions.PublishingError)
            d.addCallback(checkPublish)

        s = ZmqPubConnection(
            ZmqEndpoint(ZmqEndpointType.bind, "inproc://#1"))
        self.patch(s, 'send', fakeSend)
        d = s.listen(self.factory)
        d.addCallback(checkListen)
        return d
    def test_publish_success(self):

        def fakeSend(message):
            self.factory.testMessage = message

        def checkPublish(server):
            expected = "\x00a really special message"
            self.assertEqual(self.factory.testMessage, expected)

        def checkListen(server):
            self.assertEqual(self.factory.testMessage, "")
            d = server.publish("a really special message")
            d.addCallback(checkPublish)

        s = ZmqPubConnection(
            ZmqEndpoint(ZmqEndpointType.bind, "inproc://#1"))
        self.patch(s, 'send', fakeSend)
        d = s.listen(self.factory)
        d.addCallback(checkListen)
        return d