本文整理汇总了Python中sbp.msg.SBP.unpack方法的典型用法代码示例。如果您正苦于以下问题:Python SBP.unpack方法的具体用法?Python SBP.unpack怎么用?Python SBP.unpack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sbp.msg.SBP
的用法示例。
在下文中一共展示了SBP.unpack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assert_package
# 需要导入模块: from sbp.msg import SBP [as 别名]
# 或者: from sbp.msg.SBP import unpack [as 别名]
def assert_package(test_filename, pkg_name):
"""
Runs unit tests for message bindings by reading a YAML unit test
specification, parsing a raw packet for each test, and then
asserting that SBP messages and parsed payloads have their intended
values.
Parameters
----------
test_filename : str
Filepath to unit test specifications
pkg_name : str
Name of package to test
"""
with open(test_filename, 'r') as f:
pkg = yaml.load(f.read())
_assert_sane_package(pkg_name, pkg)
for test_case in pkg['tests']:
sbp = SBP.unpack(base64.standard_b64decode(test_case['raw_packet']))
_assert_sbp(sbp, test_case['sbp'])
_assert_msg(dispatch(sbp), test_case['msg'])
_assert_msg_roundtrip(dispatch(sbp), test_case['raw_packet'])
_assert_msg_roundtrip_json(dispatch(sbp), test_case['raw_json'])
_assert_materialization(test_case['msg'], sbp, test_case['raw_json'])