test_util.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:Jackal_Velodyne_Duke 作者: MengGuo 项目源码 文件源码
def test_to_bytes(self):
        self.assertEqual(serial.to_bytes([1, 2, 3]), b'\x01\x02\x03')
        self.assertEqual(serial.to_bytes(b'\x01\x02\x03'), b'\x01\x02\x03')
        self.assertEqual(serial.to_bytes(bytearray([1,2,3])), b'\x01\x02\x03')
        # unicode is not supported test. use decode() instead of u'' syntax to be
        # compatible to Python 3.x < 3.4
        self.assertRaises(TypeError, serial.to_bytes, b'hello'.decode('utf-8'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号