本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)