https://github.com/python/cpython/commit/251667340e9994ed209e2f53f923ac9fb24b3974
commit: 251667340e9994ed209e2f53f923ac9fb24b3974
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: pablogsal <[email protected]>
date: 2024-07-03T11:11:41Z
summary:

[3.13] gh-121245: a regression test for site.register_readline() (GH-121259) 
(#121322)

files:
M Lib/test/test_pyrepl/test_pyrepl.py

diff --git a/Lib/test/test_pyrepl/test_pyrepl.py 
b/Lib/test/test_pyrepl/test_pyrepl.py
index b189d3291e8181..93c80467a04546 100644
--- a/Lib/test/test_pyrepl/test_pyrepl.py
+++ b/Lib/test/test_pyrepl/test_pyrepl.py
@@ -1,14 +1,17 @@
 import io
 import itertools
 import os
+import pathlib
 import rlcompleter
 import select
 import subprocess
 import sys
+import tempfile
 from unittest import TestCase, skipUnless
 from unittest.mock import patch
 from test.support import force_not_colorized
 from test.support import SHORT_TIMEOUT
+from test.support.os_helper import unlink
 
 from .support import (
     FakeConsole,
@@ -898,6 +901,30 @@ def test_python_basic_repl(self):
         self.assertNotIn("Exception", output)
         self.assertNotIn("Traceback", output)
 
+    def test_not_wiping_history_file(self):
+        hfile = tempfile.NamedTemporaryFile(delete=False)
+        self.addCleanup(unlink, hfile.name)
+        env = os.environ.copy()
+        env["PYTHON_HISTORY"] = hfile.name
+        commands = "123\nspam\nexit()\n"
+
+        env.pop("PYTHON_BASIC_REPL", None)
+        output, exit_code = self.run_repl(commands, env=env)
+        self.assertEqual(exit_code, 0)
+        self.assertIn("123", output)
+        self.assertIn("spam", output)
+        self.assertNotEqual(pathlib.Path(hfile.name).stat().st_size, 0)
+
+        hfile.file.truncate()
+        hfile.close()
+
+        env["PYTHON_BASIC_REPL"] = "1"
+        output, exit_code = self.run_repl(commands, env=env)
+        self.assertEqual(exit_code, 0)
+        self.assertIn("123", output)
+        self.assertIn("spam", output)
+        self.assertNotEqual(pathlib.Path(hfile.name).stat().st_size, 0)
+
     def run_repl(self, repl_input: str | list[str], env: dict | None = None) 
-> tuple[str, int]:
         master_fd, slave_fd = pty.openpty()
         process = subprocess.Popen(

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to