本文整理匯總了Python中oslo_versionedobjects.fields.List方法的典型用法代碼示例。如果您正苦於以下問題:Python fields.List方法的具體用法?Python fields.List怎麽用?Python fields.List使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類oslo_versionedobjects.fields
的用法示例。
在下文中一共展示了fields.List方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from oslo_versionedobjects import fields [as 別名]
# 或者: from oslo_versionedobjects.fields import List [as 別名]
def __init__(self, objtype, subclasses=False, **kwargs):
self.AUTO_TYPE = ovoo_fields.List(
PolymorphicObject(objtype, subclasses))
self.objname = objtype
super(PolymorphicListOfObjectsField, self).__init__(**kwargs)
示例2: setUp
# 需要導入模塊: from oslo_versionedobjects import fields [as 別名]
# 或者: from oslo_versionedobjects.fields import List [as 別名]
def setUp(self):
super(TestList, self).setUp()
self.field = fields.Field(fields.List(FakeFieldType()))
self.coerce_good_values = [(['foo', 'bar'], ['*foo*', '*bar*'])]
self.coerce_bad_values = ['foo']
self.to_primitive_values = [(['foo'], ['!foo!'])]
self.from_primitive_values = [(['!foo!'], ['foo'])]
示例3: test_regular_list
# 需要導入模塊: from oslo_versionedobjects import fields [as 別名]
# 或者: from oslo_versionedobjects.fields import List [as 別名]
def test_regular_list(self):
fields.List(fields.Integer).coerce(None, None, [1, 2])
示例4: test_non_iterable
# 需要導入模塊: from oslo_versionedobjects import fields [as 別名]
# 或者: from oslo_versionedobjects.fields import List [as 別名]
def test_non_iterable(self):
self.assertRaises(ValueError,
fields.List(fields.Integer).coerce, None, None, 2)
示例5: test_string_iterable
# 需要導入模塊: from oslo_versionedobjects import fields [as 別名]
# 或者: from oslo_versionedobjects.fields import List [as 別名]
def test_string_iterable(self):
self.assertRaises(ValueError,
fields.List(fields.Integer).coerce, None, None,
'hello')
示例6: test_mapping_iterable
# 需要導入模塊: from oslo_versionedobjects import fields [as 別名]
# 或者: from oslo_versionedobjects.fields import List [as 別名]
def test_mapping_iterable(self):
self.assertRaises(ValueError,
fields.List(fields.Integer).coerce, None, None,
{'a': 1, 'b': 2})