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


Python ConstBitStream.tobytes方法代码示例

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


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

示例1: test_afi_1_with_prefixlen

# 需要导入模块: from bitstring import ConstBitStream [as 别名]
# 或者: from bitstring.ConstBitStream import tobytes [as 别名]
    def test_afi_1_with_prefixlen(self):
        '''
        Test decoding of AFI 1 (IPv4) prefixes
        '''
        afi_address_hex = '0001c0000200'
        bitstream = ConstBitStream(hex=afi_address_hex)

        address = afi.read_afi_address_from_bitstream(bitstream, 24)

        self.assertEqual(address, IPv4Network(u'192.0.2.0/24'))
        self.assertEqual(bitstream.pos, bitstream.len,
                         'unprocessed bits remaining in bitstream')

        new_bitstream = afi.get_bitstream_for_afi_address(address)

        self.assertEqual(new_bitstream.tobytes(), bitstream.tobytes())
开发者ID:SeleneLI,项目名称:LIG_measurement,代码行数:18,代码来源:test_utils_afi.py

示例2: test_afi_0_without_prefixlen

# 需要导入模块: from bitstring import ConstBitStream [as 别名]
# 或者: from bitstring.ConstBitStream import tobytes [as 别名]
    def test_afi_0_without_prefixlen(self):
        '''
        Test en/decoding of empty AFI addresses
        '''
        afi_address_hex = '0000'
        bitstream = ConstBitStream(hex=afi_address_hex)

        address = afi.read_afi_address_from_bitstream(bitstream)

        self.assertIsNone(address, 'wrong address')
        self.assertEqual(bitstream.pos, bitstream.len,
                         'unprocessed bits remaining in bitstream')

        new_bitstream = afi.get_bitstream_for_afi_address(address)

        self.assertEqual(new_bitstream.tobytes(), bitstream.tobytes())
开发者ID:SeleneLI,项目名称:LIG_measurement,代码行数:18,代码来源:test_utils_afi.py

示例3: test_afi_2_with_prefixlen

# 需要导入模块: from bitstring import ConstBitStream [as 别名]
# 或者: from bitstring.ConstBitStream import tobytes [as 别名]
    def test_afi_2_with_prefixlen(self):
        '''
        Test decoding of AFI 2 (IPv6) prefixes
        '''
        afi_address_hex = '000220010db80102abcd0000000000000000'
        bitstream = ConstBitStream(hex=afi_address_hex)

        address = afi.read_afi_address_from_bitstream(bitstream, 64)

        self.assertEqual(address, IPv6Network(u'2001:db8:102:abcd::/64'))
        self.assertEqual(bitstream.pos, bitstream.len,
                         'unprocessed bits remaining in bitstream')

        new_bitstream = afi.get_bitstream_for_afi_address(address)

        self.assertEqual(new_bitstream.tobytes(), bitstream.tobytes())
开发者ID:SeleneLI,项目名称:LIG_measurement,代码行数:18,代码来源:test_utils_afi.py

示例4: test_afi_0_with_prefixlen_0

# 需要导入模块: from bitstring import ConstBitStream [as 别名]
# 或者: from bitstring.ConstBitStream import tobytes [as 别名]
    def test_afi_0_with_prefixlen_0(self):
        '''
        Although a prefix length of 0 is allowed (since that is how many
        implementations transmit it on the wire)
        '''
        afi_address_hex = '0000'
        bitstream = ConstBitStream(hex=afi_address_hex)

        address = afi.read_afi_address_from_bitstream(bitstream, 0)

        self.assertIsNone(address, 'wrong address')
        self.assertEqual(bitstream.pos, bitstream.len,
                         'unprocessed bits remaining in bitstream')

        new_bitstream = afi.get_bitstream_for_afi_address(address)

        self.assertEqual(new_bitstream.tobytes(), bitstream.tobytes())
开发者ID:SeleneLI,项目名称:LIG_measurement,代码行数:19,代码来源:test_utils_afi.py


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