import py from vt102 import VT102 def check(vt, expected): expected = '\n'.join(expected) assert vt.screenshot() == expected def test_simple_scrolling(): vt = VT102(16, 3) vt.terminal_input('hello') check(vt, ['hello', '', '']) vt.terminal_input('\r\nworld\r\n') check(vt, ['hello', 'world', '']) vt.terminal_input('bla\r') check(vt, ['hello', 'world', 'bla']) vt.terminal_input('\n') check(vt, ['world', 'bla', '']) def test_wraparound(): vt = VT102(5, 3) vt.terminal_input('12345abcdefghij') check(vt, ['12345', 'abcde', 'fghij']) vt.terminal_input('k') check(vt, ['abcde', 'fghij', 'k'])