def test_text(self): output = TextBuffer() output.print("one two three four five six seven") output.print("eight nine ten eleven twelve thirteen fourteen fifteen") output.print("sixteen seventeen eighteen nineteen twenty.") output.p() output.print("new paragraph.") output.print("Yeah.", end=True) output.p() output.print("new paragraph after empty line.") output.p() output.p() output.print("| x x |", format=False) output.print("| y y |", format=False) output.print("| z z |", format=False) expected = """ one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty. new paragraph. Yeah. \x20\x20 new paragraph after empty line. \x20\x20 | x x | | y y | | z z | """ io = console_io.ConsoleIo(None) formatted = io.render_output(output.get_paragraphs(), indent=2, width=45) self.assertEqual(expected, formatted)
def testApplyStyles(self): io = console_io.ConsoleIo(None) self.assertEqual("text", io._apply_style("text", True)) self.assertEqual("text", io._apply_style("text", False)) self.assertEqual("brighttext", io._apply_style("<bright>bright</>text", False)) if console_io.style_words: self.assertIn("bright", console_io.style_words) self.assertIn("/", console_io.style_words) bx = console_io.style_words["bright"] rs = console_io.style_words["/"] expected = bx + "bright" + rs + "text" self.assertEqual(expected, io._apply_style("<bright>bright</>text", True))
def test_basic(self): io = console_io.ConsoleIo(None) io.break_pressed() io.output("line1", "line2")