本文整理匯總了Python中xatro.world.World.create方法的典型用法代碼示例。如果您正苦於以下問題:Python World.create方法的具體用法?Python World.create怎麽用?Python World.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xatro.world.World
的用法示例。
在下文中一共展示了World.create方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_execute
# 需要導入模塊: from xatro.world import World [as 別名]
# 或者: from xatro.world.World import create [as 別名]
def test_execute(self):
"""
Listing squares should return a list of all the things in the world
which are squares. It should include their coordinates and number of
each kind of thing inside them.
"""
world = World(MagicMock())
s1 = world.create('square')['id']
s2 = world.create('square')['id']
world.setAttr(s2, 'coordinates', (0, 1))
thing1 = world.create('thing')['id']
Move(thing1, s2).execute(world)
output = ListSquares(thing1).execute(world)
self.assertIn({
'id': s1,
'kind': 'square',
'coordinates': None,
'contents': {},
}, output)
self.assertIn({
'id': s2,
'kind': 'square',
'coordinates': (0, 1),
'contents': {
'thing': 1,
}
}, output)
self.assertEqual(len(output), 2)