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


Python Builder.set_template方法代码示例

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


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

示例1: test_correct_number_of_fields

# 需要导入模块: from builder import Builder [as 别名]
# 或者: from builder.Builder import set_template [as 别名]
    def test_correct_number_of_fields(self):
        b = Builder()

        b.set_template(TMPL_TWO_FIELDS)
        b.prepare()

        self.assertEqual(2, b.count())
开发者ID:Atlantic777,项目名称:packet_builder,代码行数:9,代码来源:test.py

示例2: test_get_raw

# 需要导入模块: from builder import Builder [as 别名]
# 或者: from builder.Builder import set_template [as 别名]
    def test_get_raw(self):
        b = Builder()
        b.set_template("foo[1] = 1, foe[2] = 2")
        b.prepare()

        self.assertTrue(b.is_correct())

        target = "\x01\x00\x02"
        self.assertEqual(target, b.get_raw())
开发者ID:Atlantic777,项目名称:packet_builder,代码行数:11,代码来源:test.py

示例3: test_correct_sizes_of_fields

# 需要导入模块: from builder import Builder [as 别名]
# 或者: from builder.Builder import set_template [as 别名]
    def test_correct_sizes_of_fields(self):
        b = Builder()

        b.set_template(TMPL_TWO_FIELDS)
        b.prepare()

        fields = b.get_fields()

        self.assertEqual(1, fields["foo"].size)
        self.assertEqual(2, fields["foe"].size)
开发者ID:Atlantic777,项目名称:packet_builder,代码行数:12,代码来源:test.py

示例4: test_correct_names_of_fields

# 需要导入模块: from builder import Builder [as 别名]
# 或者: from builder.Builder import set_template [as 别名]
    def test_correct_names_of_fields(self):
        b = Builder()

        b.set_template(TMPL_TWO_FIELDS)
        b.prepare()

        fields = b.get_fields()

        self.assertEqual(2, len(fields))
        self.assertTrue("foo" in fields)
        self.assertTrue("foe" in fields)
开发者ID:Atlantic777,项目名称:packet_builder,代码行数:13,代码来源:test.py

示例5: test_is_correct

# 需要导入模块: from builder import Builder [as 别名]
# 或者: from builder.Builder import set_template [as 别名]
    def test_is_correct(self):
        b = Builder()
        b.set_template(TMPL_TWO_FIELDS)
        b.prepare()
        self.assertFalse(b.is_correct())

        b = Builder()
        b.set_template("foo[1] = 128")
        b.prepare()
        self.assertTrue(b.is_correct())

        b = Builder()
        b.set_template("foo[1] = 0, foe[2], bar[1] = 2")
        b.prepare()
        self.assertFalse(b.is_correct())

        b.fields["foe"].value = 3
        self.assertTrue(b.is_correct())
开发者ID:Atlantic777,项目名称:packet_builder,代码行数:20,代码来源:test.py

示例6: test_set_template

# 需要导入模块: from builder import Builder [as 别名]
# 或者: from builder.Builder import set_template [as 别名]
    def test_set_template(self):
        b = Builder()

        b.set_template(TMPL_TWO_FIELDS)

        self.assertEqual(TMPL_TWO_FIELDS, b.template)
开发者ID:Atlantic777,项目名称:packet_builder,代码行数:8,代码来源:test.py


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