code: def test_emacs_cursor_movements():
      """
      Test cursor movements with Emacs key bindings.
      """
      # ControlA (beginning-of-line)
      result, cli = _feed_cli_with_input("hello\x01X\n")
      assert result.text == "Xhello"
  
      # ControlE (end-of-line)
      result, cli = _feed_cli_with_input("hello\x01X\x05Y\n")
      assert result.text == "XhelloY"
  
      # ControlH or \b
      result, cli = _feed_cli_with_input("hello\x08X\n")
      assert result.text == "hellX"
  
      # Delete.  (Left, left, delete)
      result, cli = _feed_cli_with_input("hello\x1b[D\x1b[D\x1b[3~\n")
      assert result.text == "helo"
  
      # Left.
      result, cli = _feed_cli_with_input("hello\x1b[DX\n")
      assert result.text == "hellXo"
  
      # ControlA, right
      result, cli = _feed_cli_with_input("hello\x01\x1b[CX\n")
      assert result.text == "hXello"
  
      # ControlA, right
      result, cli = _feed_cli_with_input("hello\x01\x1b[CX\n")
      assert result.text == "hXello"
  
      # ControlB (backward-char)
      result, cli = _feed_cli_with_input("hello\x02X\n")
      assert result.text == "hellXo"
  
      # ControlF (forward-char)
      result, cli = _feed_cli_with_input("hello\x01\x06X\n")
      assert result.text == "hXello"
  
      # ControlC: raise KeyboardInterrupt.
      with pytest.raises(KeyboardInterrupt):
          result, cli = _feed_cli_with_input("hello\x03\n")
          assert result.text == "hello"
  
      # ControlD without any input: raises EOFError.
      with pytest.raises(EOFError):
          result, cli = _feed_cli_with_input("\x04\n")
          assert result.text == "hello"
  
      # ControlD: delete after cursor.
      result, cli = _feed_cli_with_input("hello\x01\x04\n")
      assert result.text == "ello"
  
      # ControlD at the end of the input ssshould not do anything.
      result, cli = _feed_cli_with_input("hello\x04\n")
      assert result.text == "hello"
  
      # Left, Left, ControlK  (kill-line)
      result, cli = _feed_cli_with_input("hello\x1b[D\x1b[D\x0b\n")
      assert result.text == "hel"
  
      # Left, Left Esc- ControlK (kill-line, but negative)
      result, cli = _feed_cli_with_input("hello\x1b[D\x1b[D\x1b-\x0b\n")
      assert result.text == "lo"
  
      # ControlL: should not influence the result.
      result, cli = _feed_cli_with_input("hello\x0c\n")
      assert result.text == "hello"
  
      # ControlRight (forward-word)
      result, cli = _feed_cli_with_input("hello world\x01X\x1b[1;5CY\n")
      assert result.text == "XhelloY world"
  
      # ContrlolLeft (backward-word)
      result, cli = _feed_cli_with_input("hello world\x1b[1;5DY\n")
      assert result.text == "hello Yworld"
  
      # <esc>-f with argument. (forward-word)
      result, cli = _feed_cli_with_input(
          "hello world abc def\x01\x1b3\x1bfX\n"
      )
      assert result.text == "hello world abcX def"
  
      # <esc>-f with negative argument. (forward-word)
      result, cli = _feed_cli_with_input(
          "hello world abc def\x1b-\x1b3\x1bfX\n"
      )
      assert result.text == "hello Xworld abc def"
  
      # <esc>-b with argument. (backward-word)
      result, cli = _feed_cli_with_input(
          "hello world abc def\x1b3\x1bbX\n"
      )
      assert result.text == "hello Xworld abc def"
  
      # <esc>-b with negative argument. (backward-word)
      result, cli = _feed_cli_with_input(
          "hello world abc def\x01\x1b-\x1b3\x1bbX\n"
      )
      assert result.text == "hello world abc Xdef"
  
      # ControlW (kill-word / unix-word-rubout)
      result, cli = _feed_cli_with_input("hello world\x17\n")
      assert result.text == "hello "
      assert cli.clipboard.get_data().text == "world"
  
      result, cli = _feed_cli_with_input("test hello world\x1b2\x17\n")
      assert result.text == "test "
  
      # Escape Backspace (unix-word-rubout)
      result, cli = _feed_cli_with_input("hello world\x1b\x7f\n")
      assert result.text == "hello "
      assert cli.clipboard.get_data().text == "world"
  
      result, cli = _feed_cli_with_input("hello world\x1b\x08\n")
      assert result.text == "hello "
      assert cli.clipboard.get_data().text == "world"
  
      # Backspace (backward-delete-char)
      result, cli = _feed_cli_with_input("hello world\x7f\n")
      assert result.text == "hello worl"
      assert result.cursor_position == len("hello worl")
  
      result, cli = _feed_cli_with_input("hello world\x08\n")
      assert result.text == "hello worl"
      assert result.cursor_position == len("hello worl")
  
      # Delete (delete-char)
      result, cli = _feed_cli_with_input("hello world\x01\x1b[3~\n")
      assert result.text == "ello world"
      assert result.cursor_position == 0
  
      # Escape-\\ (delete-horizontal-space)
      result, cli = _feed_cli_with_input(
          "hello     world\x1b8\x02\x1b\\\n"
      )
      assert result.text == "helloworld"
      assert result.cursor_position == len("hello")
  
imports: from __future__ import unicode_literals
  from prompt_toolkit.application import Application
  from prompt_toolkit.buffer import Buffer, AcceptAction
  from prompt_toolkit.clipboard import InMemoryClipboard, ClipboardData
  from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
  from prompt_toolkit.eventloop.posix import PosixEventLoop
  from prompt_toolkit.history import InMemoryHistory
  from prompt_toolkit.input import PipeInput
  from prompt_toolkit.interface import CommandLineInterface
  from prompt_toolkit.key_binding.manager import KeyBindingManager
  from prompt_toolkit.output import DummyOutput
  from prompt_toolkit.terminal.vt100_input import ANSI_SEQUENCES
  from functools import partial
  import pytest
label_desc: Use image node_id 4 for calling a global function with example usage: test_emacs_cursor_movements() without return types