本文整理汇总了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
示例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