本文整理汇总了Python中tale.player.Player.test_get_output_paragraphs方法的典型用法代码示例。如果您正苦于以下问题:Python Player.test_get_output_paragraphs方法的具体用法?Python Player.test_get_output_paragraphs怎么用?Python Player.test_get_output_paragraphs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tale.player.Player
的用法示例。
在下文中一共展示了Player.test_get_output_paragraphs方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_wiretap
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import test_get_output_paragraphs [as 别名]
def test_wiretap(self):
attic = Location("Attic", "A dark attic.")
player = Player("fritz", "m")
io = ConsoleIo(None)
io.supports_smartquotes = False
pc = PlayerConnection(player, io)
player.set_screen_sizes(0, 100)
julie = NPC("julie", "f")
julie.move(attic)
player.move(attic)
julie.tell("message for julie")
attic.tell("message for room")
self.assertEqual(["message for room\n"], player.test_get_output_paragraphs())
with self.assertRaises(ActionRefused):
player.create_wiretap(julie)
player.privileges = {"wizard"}
player.create_wiretap(julie)
player.create_wiretap(attic)
julie.tell("message for julie")
attic.tell("message for room")
pubsub.sync()
output = pc.get_output()
self.assertTrue("[wiretapped from 'Attic': message for room]" in output)
self.assertTrue("[wiretapped from 'julie': message for julie]" in output)
self.assertTrue("[wiretapped from 'julie': message for room]" in output)
self.assertTrue("message for room " in output)
# test removing the wiretaps
player.clear_wiretaps()
import gc
gc.collect()
julie.tell("message for julie")
attic.tell("message for room")
self.assertEqual(["message for room\n"], player.test_get_output_paragraphs())
示例2: test_look_brief
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import test_get_output_paragraphs [as 别名]
def test_look_brief(self):
player = Player("fritz", "m")
attic = Location("Attic", "A dark attic.")
cellar = Location("Cellar", "A gloomy cellar.")
julie = NPC("julie", "f")
julie.move(attic, silent=True)
player.move(attic, silent=True)
player.brief = 0 # default setting: always long descriptions
player.look()
self.assertEqual(["[Attic]\n", "A dark attic.\n", "Julie is here.\n"], player.test_get_output_paragraphs())
player.look()
self.assertEqual(["[Attic]\n", "A dark attic.\n", "Julie is here.\n"], player.test_get_output_paragraphs())
player.look(short=True) # override
self.assertEqual(["[Attic]\n", "Present: julie\n"], player.test_get_output_paragraphs())
player.brief = 1 # short for known, long for new locations
player.look()
self.assertEqual(["[Attic]\n", "Present: julie\n"], player.test_get_output_paragraphs())
player.move(cellar, silent=True)
player.look()
self.assertEqual(["[Cellar]\n", "A gloomy cellar.\n"], player.test_get_output_paragraphs())
player.look()
self.assertEqual(["[Cellar]\n"], player.test_get_output_paragraphs())
player.brief = 2 # short always
player.known_locations.clear()
player.look()
self.assertEqual(["[Cellar]\n"], player.test_get_output_paragraphs())
player.move(attic, silent=True)
player.look()
self.assertEqual(["[Attic]\n", "Present: julie\n"], player.test_get_output_paragraphs())
player.look(short=True) # override
self.assertEqual(["[Attic]\n", "Present: julie\n"], player.test_get_output_paragraphs())
player.look(short=False) # override
self.assertEqual(["[Attic]\n", "A dark attic.\n", "Julie is here.\n"], player.test_get_output_paragraphs())
示例3: test_tell_emptystring
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import test_get_output_paragraphs [as 别名]
def test_tell_emptystring(self):
player = Player("fritz", "m")
player.tell("", end=False)
self.assertEqual([], player.test_get_output_paragraphs())
player.tell("", end=True)
self.assertEqual(["\n"], player.test_get_output_paragraphs())
player.tell("", end=True)
player.tell("", end=True)
self.assertEqual(["\n", "\n"], player.test_get_output_paragraphs())
示例4: test_look
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import test_get_output_paragraphs [as 别名]
def test_look(self):
player = Player("fritz", "m")
attic = Location("Attic", "A dark attic.")
player.look()
self.assertEqual(["[Limbo]\n", "The intermediate or transitional place or state. There's only nothingness.\nLiving beings end up here if they're not in a proper location yet.\n"], player.test_get_output_paragraphs())
player.move(attic, silent=True)
player.look(short=True)
self.assertEqual(["[Attic]\n"], player.test_get_output_paragraphs())
julie = NPC("julie", "f")
julie.move(attic, silent=True)
player.look(short=True)
self.assertEqual(["[Attic]\n", "Present: julie\n"], player.test_get_output_paragraphs())
示例5: test_tell_formatted
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import test_get_output_paragraphs [as 别名]
def test_tell_formatted(self):
player = Player("fritz", "m")
pc = PlayerConnection(player, ConsoleIo(None))
player.set_screen_sizes(0, 100)
player.tell("line1")
player.tell("line2", "\n")
player.tell("hello\nnewline")
player.tell("\n") # paragraph separator
player.tell("ints", 42, 999)
self.assertEqual("line1 line2 hello newline\nints 42 999\n", pc.get_output())
player.tell("para1", end=False)
player.tell("para2", end=True)
player.tell("para3")
player.tell("\n")
player.tell("para4", "\n", "para5")
self.assertEqual("para1 para2\npara3\npara4 para5\n", pc.get_output())
player.tell("word " * 30)
self.assertNotEqual(("word " * 30).strip(), pc.get_output())
player.tell("word " * 30, format=False)
self.assertEqual(("word " * 30) + "\n", pc.get_output()) # when format=False output should be unformatted
player.tell(" xyz \n 123", format=False)
self.assertEqual(" xyz \n 123\n", pc.get_output())
player.tell("line1", end=True)
player.tell("\n")
player.tell("line2", end=True)
player.tell("\n")
player.tell("\n")
self.assertEqual(["line1\n", "\n", "line2\n", "\n", "\n"], player.test_get_output_paragraphs())
player.tell("line1", end=True)
player.tell("\n")
player.tell("line2", end=True)
player.tell("\n")
player.tell("\n")
self.assertEqual("line1\n\nline2\n\n\n", pc.get_output())
示例6: test_tell_sep
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import test_get_output_paragraphs [as 别名]
def test_tell_sep(self):
player = Player("fritz", "m")
pc = PlayerConnection(player, ConsoleIo(None))
player.set_screen_sizes(0, 10)
player.tell("apple", "bee", "zinc", "rose")
self.assertEqual(["apple bee zinc rose\n"], player.test_get_output_paragraphs())
pc.get_output()
player.tell("apple", "bee", "zinc", "rose", format=False)
self.assertEqual("apple\nbee\nzinc\nrose\n", pc.get_output())
示例7: test_tell_formats
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import test_get_output_paragraphs [as 别名]
def test_tell_formats(self):
player = Player("fritz", "m")
pc = PlayerConnection(player, ConsoleIo(None))
player.set_screen_sizes(0, 100)
player.tell("a b c", format=True)
player.tell("d e f", format=True)
self.assertEqual(["a b c\nd e f\n"], player.test_get_output_paragraphs())
player.tell("a b c", format=True)
player.tell("d e f", format=True)
self.assertEqual("a b c d e f\n", pc.get_output())
player.tell("a b c", format=False)
player.tell("d e f", format=False)
self.assertEqual(["a b c\nd e f\n"], player.test_get_output_paragraphs())
player.tell("a b c", format=False)
player.tell("d e f", format=False)
self.assertEqual("a b c\nd e f\n", pc.get_output())
player.tell("a b c", format=True)
player.tell("d e f", format=False)
self.assertEqual(["a b c\n", "d e f\n"], player.test_get_output_paragraphs())
player.tell("a b c", format=True)
player.tell("d e f", format=False)
self.assertEqual("a b c\nd e f\n", pc.get_output())
示例8: test_others
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import test_get_output_paragraphs [as 别名]
def test_others(self):
attic = Location("Attic", "A dark attic.")
player = Player("merlin", "m")
player.title = "wizard Merlin"
julie = MsgTraceNPC("julie", "f", "human")
fritz = MsgTraceNPC("fritz", "m", "human")
julie.move(attic, silent=True)
fritz.move(attic, silent=True)
player.move(attic, silent=True)
player.tell_others("one", "two", "three")
self.assertEqual([], player.test_get_output_paragraphs())
self.assertEqual(["one", "two", "three"], fritz.messages)
self.assertEqual(["one", "two", "three"], julie.messages)
fritz.clearmessages()
julie.clearmessages()
player.tell_others("{title} and {Title}")
self.assertEqual(["wizard Merlin and Wizard Merlin"], fritz.messages)
示例9: test_print_location
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import test_get_output_paragraphs [as 别名]
def test_print_location(self):
p = Player("julie", "f")
key = Item("key")
bag = Container("bag")
room = Location("room")
bag.insert(key, p)
p.insert(bag, p)
room.insert(p, p)
with self.assertRaises(Exception):
p.tell_object_location(None, None)
p.tell_object_location(key, None)
self.assertEqual(["(It's not clear where key is).\n"], p.test_get_output_paragraphs())
p.tell_object_location(key, None, print_parentheses=False)
self.assertEqual(["It's not clear where key is.\n"], p.test_get_output_paragraphs())
p.tell_object_location(key, bag)
result = "".join(p.test_get_output_paragraphs())
self.assertTrue("in bag" in result and "in your inventory" in result)
p.tell_object_location(key, room)
self.assertTrue("in your current location" in "".join(p.test_get_output_paragraphs()))
p.tell_object_location(bag, p)
self.assertTrue("in your inventory" in "".join(p.test_get_output_paragraphs()))
p.tell_object_location(p, room)
self.assertTrue("in your current location" in "".join(p.test_get_output_paragraphs()))
示例10: test_tell_chain
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import test_get_output_paragraphs [as 别名]
def test_tell_chain(self):
player = Player("fritz", "m")
player.tell("hi").tell("there")
self.assertEqual(["hi\nthere\n"], player.test_get_output_paragraphs())
示例11: test_tell
# 需要导入模块: from tale.player import Player [as 别名]
# 或者: from tale.player.Player import test_get_output_paragraphs [as 别名]
def test_tell(self):
player = Player("fritz", "m")
player.tell(5)
self.assertEqual(["5\n"], player.test_get_output_paragraphs())
player.tell("")
self.assertEqual([], player.test_get_output_paragraphs())
player.tell("")
player.tell("")
self.assertEqual([], player.test_get_output_paragraphs())
player.tell("")
player.tell("line1")
player.tell("line2")
player.tell("")
self.assertEqual(["line1\nline2\n"], player.test_get_output_paragraphs())
player.tell("", format=False)
player.tell("line1", format=False)
player.tell("", format=False)
player.tell("line2", format=False)
player.tell("", format=False)
self.assertEqual(["\nline1\n\nline2\n\n"], player.test_get_output_paragraphs())
player.tell("\n")
self.assertEqual(["\n"], player.test_get_output_paragraphs())
player.tell("line1")
player.tell("line2")
player.tell("hello\nnewline")
player.tell("\n")
player.tell("ints", 42, 999)
self.assertEqual(["line1\nline2\nhello\nnewline\n", "ints 42 999\n"], player.test_get_output_paragraphs())
self.assertEqual([], player.test_get_output_paragraphs())
player.tell("para1", end=False)
player.tell("para2", end=True)
player.tell("para3")
player.tell("\n")
player.tell("para4", "\n", "para5")
self.assertEqual(["para1\npara2\n", "para3\n", "para4 \n para5\n"], player.test_get_output_paragraphs())
player.tell(" xyz \n 123", format=False)
self.assertEqual([" xyz \n 123\n"], player.test_get_output_paragraphs())
player.tell("line1", end=True)
player.tell("\n")
player.tell("line2", end=True)
player.tell("\n")
player.tell("\n")
self.assertEqual(["line1\n", "\n", "line2\n", "\n", "\n"], player.test_get_output_paragraphs())