def test_InlinePrinter_width(self): """ Test to see if the calculated width is correct. """ printer = cp.InlinePrinter(self.cparser, u.Colors, print_colored=False) expected_length = str(len('Test Cheat A')) self.assertEqual(printer.width, expected_length)
def test_InlinePrinter(self): """ Testing if the InlinePrinter does its job. """ # Done this way for better readablility. lines = ["test cheat a lorem\n", "test cheat b ipsum\n", "test cheat c dolor\n"] expected_output = lines[0] + lines[1] + lines[2] printer = cp.InlinePrinter(self.cparser, u.colors, print_colored=False) with patch('sys.stdout', new=StringIO()) as fake_out: printer.printsheet() self.assertEqual(fake_out.getvalue(), expected_output)
def test_InlinePrinter_colored(self): """ Testing if the InlinePrinter does its job. """ # Done this way for better readablility. lines = [ "CHEATS\n", "Test cheat a \x1b[94mlorem\x1b[1;m\n", "Test cheat b \x1b[94mipsum\x1b[1;m\n", "Test cheat c \x1b[94mdolor\x1b[1;m\n" ] expected_output = ''.join(lines) printer = cp.InlinePrinter(self.cparser, u.Colors, print_colored=True) with patch('sys.stdout', new=StringIO()) as fake_out: printer.printsheet() self.assertEqual(fake_out.getvalue(), expected_output)