示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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)