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


Python World.load_player方法代码示例

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


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

示例1: TestWorld

# 需要导入模块: from bravo.world import World [as 别名]
# 或者: from bravo.world.World import load_player [as 别名]
class TestWorld(unittest.TestCase):

    def setUp(self):
        self.name = "unittest"
        self.bcp = BravoConfigParser()

        self.bcp.add_section("world unittest")
        self.bcp.set("world unittest", "url", "")
        self.bcp.set("world unittest", "serializer", "memory")

        self.w = World(self.bcp, self.name)
        self.w.pipeline = []
        self.w.start()

    def tearDown(self):
        self.w.stop()

    def test_trivial(self):
        pass

    def test_load_player_initial(self):
        """
        Calling load_player() on a player which has never been loaded should
        not result in an exception. Instead, the player should be returned,
        wrapped in a Deferred.
        """

        # For bonus points, assert that the player's username is correct.
        d = self.w.load_player("unittest")

        @d.addCallback
        def cb(player):
            self.assertEqual(player.username, "unittest")
        return d
开发者ID:KingPsychopath,项目名称:bravo,代码行数:36,代码来源:test_world.py

示例2: TestWorld

# 需要导入模块: from bravo.world import World [as 别名]
# 或者: from bravo.world.World import load_player [as 别名]
class TestWorld(unittest.TestCase):

    def setUp(self):
        self.name = "unittest"
        self.d = tempfile.mkdtemp()

        bravo.config.configuration.add_section("world unittest")
        bravo.config.configuration.set("world unittest", "url", "file://%s" % self.d)
        bravo.config.configuration.set("world unittest", "serializer",
            "alpha")

        self.w = World(self.name)
        self.w.pipeline = []
        self.w.start()

    def tearDown(self):
        self.w.stop()
        del self.w

        shutil.rmtree(self.d)
        bravo.config.configuration.remove_section("world unittest")

    def test_trivial(self):
        pass

    def test_load_player_initial(self):
        """
        Calling load_player() on a player which has never been loaded should
        not result in an exception. Instead, the player should be returned,
        wrapped in a Deferred.
        """

        # For bonus points, assert that the player's username is correct.
        d = self.w.load_player("unittest")
        @d.addCallback
        def cb(player):
            self.assertEqual(player.username, "unittest")
        return d
开发者ID:mmcgill,项目名称:bravo,代码行数:40,代码来源:test_world.py


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