本文整理汇总了Python中xatro.world.World.onBecome方法的典型用法代码示例。如果您正苦于以下问题:Python World.onBecome方法的具体用法?Python World.onBecome怎么用?Python World.onBecome使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xatro.world.World
的用法示例。
在下文中一共展示了World.onBecome方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_onBecome_cancel
# 需要导入模块: from xatro.world import World [as 别名]
# 或者: from xatro.world.World import onBecome [as 别名]
def test_onBecome_cancel(self):
"""
You can cancel the deferred returned by onBecome
"""
world = World(MagicMock())
obj = world.create('foo')
d = world.onBecome(obj['id'], 'hey', 3)
d.cancel()
world.setAttr(obj['id'], 'hey', 3)
self.assertFailure(d, defer.CancelledError)
示例2: test_onBecome
# 需要导入模块: from xatro.world import World [as 别名]
# 或者: from xatro.world.World import onBecome [as 别名]
def test_onBecome(self):
"""
You can get a Deferred which will fire when an attribute becomes a
particular value.
"""
world = World(MagicMock())
obj = world.create('foo')
d = world.onBecome(obj['id'], 'hey', 3)
self.assertFalse(d.called)
world.setAttr(obj['id'], 'hey', 3)
self.assertEqual(self.successResultOf(d), 3)
# make sure it isn't called again
world.setAttr(obj['id'], 'hey', 2)
world.setAttr(obj['id'], 'hey', 3)