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