code: def test_emacs_history_bindings():
      # Adding a new item to the history.
      history = _history()
      result, cli = _feed_cli_with_input("new input\r", history=history)
      assert result.text == "new input"
      history.get_strings()[-1] == "new input"
  
      # Go up in history, and accept the last item.
      result, cli = _feed_cli_with_input(
          "hello\x1b[A\r", history=history
      )
      assert result.text == "new input"
  
      # Esc< (beginning-of-history)
      result, cli = _feed_cli_with_input(
          "hello\x1b<\r", history=history
      )
      assert result.text == "line1 first input"
  
      # Esc> (end-of-history)
      result, cli = _feed_cli_with_input(
          "another item\x1b[A\x1b[a\x1b>\r", history=history
      )
      assert result.text == "another item"
  
      # ControlUp (previous-history)
      result, cli = _feed_cli_with_input("\x1b[1;5A\r", history=history)
      assert result.text == "another item"
  
      # Esc< ControlDown (beginning-of-history, next-history)
      result, cli = _feed_cli_with_input(
          "\x1b<\x1b[1;5B\r", history=history
      )
      assert result.text == "line2 second input"
  
imports: from __future__ import annotations
  from functools import partial
  import pytest
  from prompt_toolkit.clipboard import ClipboardData, InMemoryClipboard
  from prompt_toolkit.enums import EditingMode
  from prompt_toolkit.filters import ViInsertMode
  from prompt_toolkit.history import InMemoryHistory
  from prompt_toolkit.input.defaults import create_pipe_input
  from prompt_toolkit.input.vt100_parser import ANSI_SEQUENCES
  from prompt_toolkit.key_binding.bindings.named_commands import prefix_meta
  from prompt_toolkit.key_binding.key_bindings import KeyBindings
  from prompt_toolkit.output import DummyOutput
  from prompt_toolkit.shortcuts import PromptSession
label_desc: Use image node_id 12 for calling a global function with example usage: test_emacs_history_bindings() without return types