Skip to content

Commit

Permalink
add Test to moveCursor
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbautista committed Aug 5, 2024
1 parent 95f2498 commit a711809
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions qtconsole/tests/test_ansi_code_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,44 @@ def test_combined(self):
self.assertEqual(splits, ['abc', None, 'def', None])
self.assertEqual(actions, [[], ['carriage-return'], [], ['backspace']])

def test_move_cursor_up(self):
""" Do control sequences for scrolling the buffer work?
"""
string = '\x1b[A\x1b[5A\x1b[F\x1b[5F'
i = -1
for i, substring in enumerate(self.processor.split_string(string)):
if i == 0:
self.assertEqual(len(self.processor.actions), 1)
action = self.processor.actions[0]
self.assertEqual(action.action, 'move')
self.assertEqual(action.dir, 'up')
self.assertEqual(action.unit, 'line')
self.assertEqual(action.count, 1)
elif i == 1:
self.assertEqual(len(self.processor.actions), 1)
action = self.processor.actions[0]
self.assertEqual(action.action, 'move')
self.assertEqual(action.dir, 'up')
self.assertEqual(action.unit, 'line')
self.assertEqual(action.count, 5)
elif i == 2:
self.assertEqual(len(self.processor.actions), 1)
action = self.processor.actions[0]
self.assertEqual(action.action, 'move')
self.assertEqual(action.dir, 'leftup')
self.assertEqual(action.unit, 'line')
self.assertEqual(action.count, 1)
elif i == 3:
self.assertEqual(len(self.processor.actions), 1)
action = self.processor.actions[0]
self.assertEqual(action.action, 'move')
self.assertEqual(action.dir, 'leftup')
self.assertEqual(action.unit, 'line')
self.assertEqual(action.count, 5)
else:
self.fail('Too many substrings.')
self.assertEqual(i, 1, 'Too few substrings.')


if __name__ == '__main__':
unittest.main()

0 comments on commit a711809

Please sign in to comment.