本文整理汇总了Python中gnome.movers.WindMover.serialize方法的典型用法代码示例。如果您正苦于以下问题:Python WindMover.serialize方法的具体用法?Python WindMover.serialize怎么用?Python WindMover.serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnome.movers.WindMover
的用法示例。
在下文中一共展示了WindMover.serialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_serialize_deserialize
# 需要导入模块: from gnome.movers import WindMover [as 别名]
# 或者: from gnome.movers.WindMover import serialize [as 别名]
def test_serialize_deserialize(wind_circ, do):
"""
tests and illustrates the funcitonality of serialize/deserialize for
WindMover.
"""
wind = environment.Wind(filename=file_)
wm = WindMover(wind)
json_ = wm.serialize(do)
if do == 'create':
assert 'wind' not in json_
# reference to 'wind' object is made by the Model().save() function
# by default 'wind' object is not serialized in 'create' mode
# so for this test to work, add the 'wind' key, value back in before
# constructing new WindMover. In the real use case, the model does this
dict_ = wm.deserialize(json_)
dict_['wind'] = wind
wm2 = WindMover.new_from_dict(dict_)
assert wm == wm2
else:
assert 'wind' in json_
wind_update = wind_circ['wind']
json_['wind'] = wind_update.serialize(do)
dict_ = wm.deserialize(json_)
wm.from_dict(dict_)
assert wm.wind == wind_update
示例2: test_serialize_deserialize
# 需要导入模块: from gnome.movers import WindMover [as 别名]
# 或者: from gnome.movers.WindMover import serialize [as 别名]
def test_serialize_deserialize(wind_circ):
"""
tests and illustrate the funcitonality of serialize/deserialize for
WindMover.
"""
wind = Wind(filename=file_)
wm = WindMover(wind)
serial = wm.serialize()
assert 'wind' in serial
wm2 = wm.deserialize(serial)
assert wm == wm2
示例3: test_serialize_deserialize
# 需要导入模块: from gnome.movers import WindMover [as 别名]
# 或者: from gnome.movers.WindMover import serialize [as 别名]
def test_serialize_deserialize(wind_circ):
"""
tests and illustrate the funcitonality of serialize/deserialize for
WindMover.
"""
wind = Wind(filename=file_)
wm = WindMover(wind)
serial = wm.serialize('webapi')
assert 'wind' in serial
dict_ = wm.deserialize(serial)
dict_['wind'] = wind_circ['wind']
wm.update_from_dict(dict_)
assert wm.wind == wind_circ['wind']