code: def test_history_size(self):
      history_size = 10
      with temp_dir() as test_dir:
          inputrc = os.path.join(test_dir, "inputrc")
          with open(inputrc, "wb") as f:
              f.write(b"set history-size %d\n" % history_size)
  
          history_file = os.path.join(test_dir, "history")
          with open(history_file, "wb") as f:
              # history_size * 2 items crashes readline
              data = b"".join(
                  b"item %d\n" % i for i in range(history_size * 2)
              )
              f.write(data)
  
          script = """
  import os
  import readline
  
  history_file = os.environ["HISTORY_FILE"]
  readline.read_history_file(history_file)
  input()
  readline.write_history_file(history_file)
  """
  
          env = dict(os.environ)
          env["INPUTRC"] = inputrc
          env["HISTORY_FILE"] = history_file
  
          run_pty(script, input=b"last input\r", env=env)
  
          with open(history_file, "rb") as f:
              lines = f.readlines()
          self.assertEqual(len(lines), history_size)
          self.assertEqual(lines[-1].strip(), b"last input")
  
imports: import locale
  import os
  import sys
  import tempfile
  import textwrap
  import unittest
  from test.support import verbose
  from test.support.import_helper import import_module
  from test.support.os_helper import unlink, temp_dir, TESTFN
  from test.support.pty_helper import run_pty
  from test.support.script_helper import assert_python_ok
label_desc: Use image node_id 7 for calling the TestReadline obj's underlying member method code with example usage: obj.test_history_size() without return types