本文整理汇总了Python中tale.player.Player.store_input_line方法的典型用法代码示例。如果您正苦于以下问题:Python Player.store_input_line方法的具体用法?Python Player.store_input_line怎么用?Python Player.store_input_line使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tale.player.Player
的用法示例。
在下文中一共展示了Player.store_input_line方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_input
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import store_input_line [as 别名]
def test_input(self):
player = Player("julie", "f")
with WrappedConsoleIO(None) as io:
pc = PlayerConnection(player, io)
player.tell("first this text")
player.store_input_line(" input text \n")
x = pc.input_direct("inputprompt")
self.assertEqual("input text", x)
self.assertEqual(" first this text\ninputprompt ", sys.stdout.getvalue()) # should have outputted the buffered text
示例2: test_idle
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import store_input_line [as 别名]
def test_idle(self):
p = Player("dummy", "f")
c = PlayerConnection(p, WrappedConsoleIO(None))
self.assertLess(p.idle_time, 0.1)
self.assertLess(c.idle_time, 0.1)
time.sleep(0.2)
self.assertGreater(p.idle_time, 0.1)
self.assertGreater(c.idle_time, 0.1)
p.store_input_line("input")
self.assertLess(p.idle_time, 0.1)
self.assertLess(c.idle_time, 0.1)
示例3: test_input
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import store_input_line [as 别名]
def test_input(self):
player = Player("julie", "f")
player.io = ConsoleIo(None)
old_stdout = sys.stdout
sys.stdout = StringIO()
try:
player.tell("first this text")
player.store_input_line("input text\n")
x = player.input("inputprompt")
self.assertEqual("input text", x)
self.assertEqual(" first this text\ninputprompt", sys.stdout.getvalue()) # should have outputted the buffered text
finally:
sys.stdout = old_stdout