本文整理汇总了Python中pants.base.payload.Payload.freeze方法的典型用法代码示例。如果您正苦于以下问题:Python Payload.freeze方法的具体用法?Python Payload.freeze怎么用?Python Payload.freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.base.payload.Payload
的用法示例。
在下文中一共展示了Payload.freeze方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fingerprint
# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import freeze [as 别名]
def test_fingerprint(self):
payload = Payload()
payload.add_field('foo', PrimitiveField())
fingerprint1 = payload.fingerprint()
self.assertEqual(fingerprint1, payload.fingerprint())
payload.add_field('bar', PrimitiveField())
fingerprint2 = payload.fingerprint()
self.assertNotEqual(fingerprint1, fingerprint2)
self.assertEqual(fingerprint2, payload.fingerprint())
payload.freeze()
self.assertEqual(fingerprint2, payload.fingerprint())
示例2: payload_for_scope
# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import freeze [as 别名]
def payload_for_scope(self, scope):
"""Returns a payload representing the options for the given scope."""
payload = Payload()
for (name, _, kwargs) in self.registration_args_iter_for_scope(scope):
if not kwargs.get('fingerprint', False):
continue
val = self.for_scope(scope)[name]
val_type = kwargs.get('type', '')
if val_type == Options.file:
field = FileField(val)
elif val_type == Options.target_list:
field = TargetListField(val)
else:
field = PrimitiveField(val)
payload.add_field(name, field)
payload.freeze()
return payload
示例3: test_field_duplication
# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import freeze [as 别名]
def test_field_duplication(self):
payload = Payload()
payload.add_field('foo', PrimitiveField())
payload.freeze()
with self.assertRaises(PayloadFieldAlreadyDefinedError):
payload.add_field('foo', PrimitiveField())
示例4: test_freeze
# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import freeze [as 别名]
def test_freeze(self):
payload = Payload()
payload.add_field('foo', PrimitiveField())
payload.freeze()
with self.assertRaises(PayloadFrozenError):
payload.add_field('bar', PrimitiveField())
示例5: _make_payload_from_sources
# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import freeze [as 别名]
def _make_payload_from_sources(self, sources):
p = Payload()
p.add_field('sources', SourcesField('', sources))
p.freeze()
return p