当前位置: 首页>>代码示例>>Python>>正文


Python WindMover.new_from_dict方法代码示例

本文整理汇总了Python中gnome.movers.WindMover.new_from_dict方法的典型用法代码示例。如果您正苦于以下问题:Python WindMover.new_from_dict方法的具体用法?Python WindMover.new_from_dict怎么用?Python WindMover.new_from_dict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gnome.movers.WindMover的用法示例。


在下文中一共展示了WindMover.new_from_dict方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_exception_new_from_dict

# 需要导入模块: from gnome.movers import WindMover [as 别名]
# 或者: from gnome.movers.WindMover import new_from_dict [as 别名]
def test_exception_new_from_dict():

    # WindMover does not modify Wind object!

    wm = WindMover(environment.Wind(filename=file_))

    wm_state = wm.to_dict('create')
    wm_state.update({'wind': environment.Wind(filename=file_)})

    with pytest.raises(ValueError):
        WindMover.new_from_dict(wm_state)
开发者ID:JamesMakela,项目名称:GNOME2,代码行数:13,代码来源:test_wind_mover.py

示例2: test_serialize_deserialize

# 需要导入模块: from gnome.movers import WindMover [as 别名]
# 或者: from gnome.movers.WindMover import new_from_dict [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
开发者ID:kthyng,项目名称:GNOME2,代码行数:31,代码来源:test_wind_mover.py

示例3: test_new_from_dict

# 需要导入模块: from gnome.movers import WindMover [as 别名]
# 或者: from gnome.movers.WindMover import new_from_dict [as 别名]
def test_new_from_dict():
    """
    Currently only checks that new object can be created from dict
    It does not check equality of objects
    """

    wind = environment.Wind(filename=file_)
    wm = WindMover(wind)  # WindMover does not modify Wind object!
    wm_state = wm.to_dict('create')

    # must create a Wind object and add this to wm_state dict

    wind2 = environment.Wind.new_from_dict(wind.to_dict('create'))
    wm_state.update({'wind': wind2})
    wm2 = WindMover.new_from_dict(wm_state)

    assert wm is not wm2
    assert wm.wind is not wm2.wind
    assert wm == wm2
开发者ID:kthyng,项目名称:GNOME2,代码行数:21,代码来源:test_wind_mover.py

示例4: test_new_from_dict

# 需要导入模块: from gnome.movers import WindMover [as 别名]
# 或者: from gnome.movers.WindMover import new_from_dict [as 别名]
def test_new_from_dict():
    """
    Currently only checks that new object can be created from dict
    It does not check equality of objects
    """

    wind = environment.Wind(filename=file_)
    wm = WindMover(wind)  # WindMover does not modify Wind object!
    wm_state = wm.to_dict('create')

    # must create a Wind object and add this to wm_state dict

    wind2 = environment.Wind.new_from_dict(wind.to_dict('create'))
    wm_state.update({'wind': wind2})
    wm2 = WindMover.new_from_dict(wm_state)

    # check serializable state is correct

    assert all([wm.__getattribute__(k) == wm2.__getattribute__(k)
               for k in WindMover.state.get_names('create') if k
               != 'wind_id' and k != 'obj_type'])
    assert wm.wind.id == wm2.wind.id
开发者ID:JamesMakela,项目名称:GNOME2,代码行数:24,代码来源:test_wind_mover.py


注:本文中的gnome.movers.WindMover.new_from_dict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。