def testTerminalSize(self): # pylint: disable=unused-argument def StubOpen(args, *kwargs): raise IOError terminal.open = StubOpen terminal.os.environ = {} # Raise exceptions on ioctl and environ and assign a default. self.assertEqual((24, 80), terminal.TerminalSize()) terminal.os.environ = {'LINES': 'bogus', 'COLUMNS': 'bogus'} self.assertEqual((24, 80), terminal.TerminalSize()) # Still raise exception on ioctl and use environ. terminal.os.environ = {'LINES': '10', 'COLUMNS': '20'} self.assertEqual((10, 20), terminal.TerminalSize())
def testPager(self): self.assertEqual(terminal.TerminalSize()[0], self.p._cli_lines) self.p.Clear() self.assertEqual('', self.p._text) self.assertEqual(0, self.p._displayed) self.assertEqual(1, self.p._lastscroll)
def testPage(self): txt = '' for i in range(100): txt += '%d a random line of text here\n' % i self.p._text = txt self.p.Page() self.assertEqual(terminal.TerminalSize()[0]+2, sys.stdout.CountLines()) sys.stdout.output = '' self.p = terminal.Pager() self.p._text = '' for i in range(10): self.p._text += 'a' * 100 + '\n' self.p.Page() self.assertEqual(20, sys.stdout.CountLines())