当前位置: 首页>>代码示例>>Python>>正文


Python AMQPWriter.write_bit方法代码示例

本文整理汇总了Python中amqp.serialization.AMQPWriter.write_bit方法的典型用法代码示例。如果您正苦于以下问题:Python AMQPWriter.write_bit方法的具体用法?Python AMQPWriter.write_bit怎么用?Python AMQPWriter.write_bit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在amqp.serialization.AMQPWriter的用法示例。


在下文中一共展示了AMQPWriter.write_bit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_single_bit

# 需要导入模块: from amqp.serialization import AMQPWriter [as 别名]
# 或者: from amqp.serialization.AMQPWriter import write_bit [as 别名]
    def test_single_bit(self):
        for val, check in [(True, '\x01'), (False, '\x00')]:
            w = AMQPWriter()
            w.write_bit(val)
            s = w.getvalue()

            self.assertEqualBinary(s, check)

            r = AMQPReader(s)
            self.assertEqual(r.read_bit(), val)
开发者ID:UCSB-CS-RACELab,项目名称:CloudRunner,代码行数:12,代码来源:test_serialization.py

示例2: test_Channel

# 需要导入模块: from amqp.serialization import AMQPWriter [as 别名]
# 或者: from amqp.serialization.AMQPWriter import write_bit [as 别名]
class test_Channel(Case):

    def setUp(self):
        self.args = AMQPWriter()
        self.connection = Mock(name='connection')
        self.connection.channels = defaultdict(lambda: None)
        self.channel = NoOpenChannel(self.connection, channel_id=1)

    def test_basic_nack(self, delivery_tag=3172312312):
        self.args.write_longlong(delivery_tag)
        self.args.write_bit(0)
        self.args.write_bit(0)
        with self.assertRaises(NotConfirmed):
            self.channel._basic_nack(AMQPReader(self.args.getvalue()))
        callback = Mock(name='callback')
        self.channel.events['basic_nack'].add(callback)
        self.channel._basic_nack(AMQPReader(self.args.getvalue()))
        callback.assert_called_with(delivery_tag, False, False)
开发者ID:1995rishi,项目名称:flaskmap,代码行数:20,代码来源:test_channel.py

示例3: test_multiple_bits3

# 需要导入模块: from amqp.serialization import AMQPWriter [as 别名]
# 或者: from amqp.serialization.AMQPWriter import write_bit [as 别名]
    def test_multiple_bits3(self):
        """
        Check bit groups that span multiple bytes
        """
        w = AMQPWriter()

        # Spit out 20 bits
        for i in range(10):
            w.write_bit(True)
            w.write_bit(False)

        s = w.getvalue()

        self.assertEqualBinary(s, '\x55\x55\x05')

        r = AMQPReader(s)
        for i in range(10):
            self.assertEqual(r.read_bit(), True)
            self.assertEqual(r.read_bit(), False)
开发者ID:UCSB-CS-RACELab,项目名称:CloudRunner,代码行数:21,代码来源:test_serialization.py

示例4: test_multiple_bits

# 需要导入模块: from amqp.serialization import AMQPWriter [as 别名]
# 或者: from amqp.serialization.AMQPWriter import write_bit [as 别名]
    def test_multiple_bits(self):
        w = AMQPWriter()
        w.write_bit(True)
        w.write_bit(True)
        w.write_bit(False)
        w.write_bit(True)
        s = w.getvalue()

        self.assertEqualBinary(s, '\x0b')

        r = AMQPReader(s)
        self.assertEqual(r.read_bit(), True)
        self.assertEqual(r.read_bit(), True)
        self.assertEqual(r.read_bit(), False)
        self.assertEqual(r.read_bit(), True)
开发者ID:UCSB-CS-RACELab,项目名称:CloudRunner,代码行数:17,代码来源:test_serialization.py

示例5: test_multiple_bits2

# 需要导入模块: from amqp.serialization import AMQPWriter [as 别名]
# 或者: from amqp.serialization.AMQPWriter import write_bit [as 别名]
    def test_multiple_bits2(self):
        """
        Check bits mixed with non-bits
        """
        w = AMQPWriter()
        w.write_bit(True)
        w.write_bit(True)
        w.write_bit(False)
        w.write_octet(10)
        w.write_bit(True)
        s = w.getvalue()

        self.assertEqualBinary(s, '\x03\x0a\x01')

        r = AMQPReader(s)
        self.assertEqual(r.read_bit(), True)
        self.assertEqual(r.read_bit(), True)
        self.assertEqual(r.read_bit(), False)
        self.assertEqual(r.read_octet(), 10)
        self.assertEqual(r.read_bit(), True)
开发者ID:UCSB-CS-RACELab,项目名称:CloudRunner,代码行数:22,代码来源:test_serialization.py


注:本文中的amqp.serialization.AMQPWriter.write_bit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。