    def test_ansi_terminal_parser_cursor(self):
        """
        Check AnsiTerminalParser cursor movement work as expected.
        """
        parser = AnsiTerminalParser()
        parser.reset("aa\x08b\rc\x1B[Cdd\x1B[De\x1B[A\x1B[B\x1B[1;2H\x1B[?25h\x1B[?25l\r", None)
        tokens = parser.parse()

        # Normal text...
        self.assertEqual(next(tokens), (0, Parser.DISPLAY_TEXT, "a"))
        self.assertEqual(next(tokens), (1, Parser.DISPLAY_TEXT, "a"))

        # Backspace and overwrite.
        self.assertEqual(next(tokens), (2, Parser.MOVE_RELATIVE, (-1, 0)))
        self.assertEqual(next(tokens), (2, Parser.DISPLAY_TEXT, "b"))

        # Carriage return and overwrite
        self.assertEqual(next(tokens), (4, Parser.MOVE_ABSOLUTE, (0, None)))
        self.assertEqual(next(tokens), (4, Parser.DISPLAY_TEXT, "c"))

        # Move cursor forwards and append.
        self.assertEqual(next(tokens), (6, Parser.MOVE_RELATIVE, (1, 0)))
        self.assertEqual(next(tokens), (6, Parser.DISPLAY_TEXT, "d"))
        self.assertEqual(next(tokens), (10, Parser.DISPLAY_TEXT, "d"))

        # Move cursor backwards and overwrite.
        self.assertEqual(next(tokens), (11, Parser.MOVE_RELATIVE, (-1, 0)))
        self.assertEqual(next(tokens), (11, Parser.DISPLAY_TEXT, "e"))

        # Move cursor up and down.
        self.assertEqual(next(tokens), (15, Parser.MOVE_RELATIVE, (0, -1)))
        self.assertEqual(next(tokens), (15, Parser.MOVE_RELATIVE, (0, 1)))

        # Move cursor to location
        self.assertEqual(next(tokens), (15, Parser.MOVE_ABSOLUTE, (1, 0)))

        # Show/hide cursor
        self.assertEqual(next(tokens), (15, Parser.SHOW_CURSOR, True))
        self.assertEqual(next(tokens), (15, Parser.SHOW_CURSOR, False))

        # Trailing Carriage return
        self.assertEqual(next(tokens), (15, Parser.MOVE_ABSOLUTE, (0, None)))
Check AnsiTerminalParser cursor movement work as expected.
tests/test_parsers.py