test_watched_property.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:EMFT 作者: 132nd-etcher 项目源码 文件源码
def test_multiple_instances():

    # Reset all watchers
    Dummy.prop._watchers = []

    o1 = Dummy()
    o2 = Dummy()

    callback = MagicMock()

    Dummy.prop.add_watcher(callback)

    assert callback.call_count == 0
    o1.prop = 'test'
    assert callback.call_count == 1
    callback.assert_called_with('test')

    o2.prop = 'caribou'
    assert callback.call_count == 2
    callback.assert_called_with('caribou')

    o2.prop = 'caribou'
    assert callback.call_count == 2
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号