本文整理匯總了Python中gnome.utilities.orderedcollection.OrderedCollection.update方法的典型用法代碼示例。如果您正苦於以下問題:Python OrderedCollection.update方法的具體用法?Python OrderedCollection.update怎麽用?Python OrderedCollection.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gnome.utilities.orderedcollection.OrderedCollection
的用法示例。
在下文中一共展示了OrderedCollection.update方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_update
# 需要導入模塊: from gnome.utilities.orderedcollection import OrderedCollection [as 別名]
# 或者: from gnome.utilities.orderedcollection.OrderedCollection import update [as 別名]
def test_update(self):
int_oc = OrderedCollection([1, 2, 3, 4, 5])
upd_cstruct = [2,3,4]
int_oc.update(upd_cstruct)
assert int_oc._elems == [2,3,4]
obj_oc = OrderedCollection([DemoObj.demo(), DemoObj.demo(), DemoObj.demo()])
obj0 = obj_oc[0]
obj1 = obj_oc[1]
assert obj_oc[0] is not obj_oc[1]
upd_list = [o.serialize() for o in obj_oc] #this is like the payload from the web client
upd_list[0]['name'] = '2nd DemoObj'
upd_list[1]['foo_float'] = 55
temp = upd_list[0]
upd_list[0] = upd_list[1]
upd_list[1] = temp
del upd_list[2]
obj_oc.update(upd_list)
assert obj_oc[0] is obj1
assert obj_oc[1] is obj0
assert obj_oc[0].foo_float == 55
assert obj_oc[0].id == upd_list[0]['id']
assert obj_oc[1].name == '2nd DemoObj'
assert obj_oc[1].id == upd_list[1]['id']
assert len(obj_oc) == 2