def test_index(): screen = HistoryScreen(5, 5, pages=10) # Filling the screen with line numbers, so it's easier to # track history contents. for idx in xrange(len(screen)): screen.draw(unicode(idx)) if idx is not len(screen) - 1: screen.linefeed() assert not screen.history.top assert not screen.history.bottom # a) first index, expecting top history to be updated. line = screen[0] screen.index() assert screen.history.top assert screen.history.top[-1] == line # b) second index. line = screen[0] screen.index() assert len(screen.history.top) == 2 assert screen.history.top[-1] == line # c) rotation. for _ in xrange(len(screen) * screen.lines): screen.index() assert len(screen.history.top) == 25 # pages // 2 * lines