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


Python World.create方法代码示例

本文整理汇总了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)
开发者ID:iffy,项目名称:xatrobots,代码行数:32,代码来源:test_action.py


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