本文整理汇总了Python中amqp.serialization.AMQPReader.read_bit方法的典型用法代码示例。如果您正苦于以下问题:Python AMQPReader.read_bit方法的具体用法?Python AMQPReader.read_bit怎么用?Python AMQPReader.read_bit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amqp.serialization.AMQPReader
的用法示例。
在下文中一共展示了AMQPReader.read_bit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_multiple_bits
# 需要导入模块: from amqp.serialization import AMQPReader [as 别名]
# 或者: from amqp.serialization.AMQPReader import read_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)
示例2: test_single_bit
# 需要导入模块: from amqp.serialization import AMQPReader [as 别名]
# 或者: from amqp.serialization.AMQPReader import read_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)
示例3: test_multiple_bits2
# 需要导入模块: from amqp.serialization import AMQPReader [as 别名]
# 或者: from amqp.serialization.AMQPReader import read_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)
示例4: test_multiple_bits3
# 需要导入模块: from amqp.serialization import AMQPReader [as 别名]
# 或者: from amqp.serialization.AMQPReader import read_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)