-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-121245: a regression test for site.register_readline() #121259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
8195067
8cbf9e5
9dd6305
4c57916
41d0f3d
595e5da
e358963
77a7baa
8ed572d
753ef78
f625be8
d3dbbfb
d4b0f10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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,19 @@ def test_python_basic_repl(self): | |
self.assertNotIn("Exception", output) | ||
self.assertNotIn("Traceback", output) | ||
|
||
def test_not_wiping_history_file(self): | ||
8000
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have tried and reverting the changes you did in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Example:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test should fail when you revert #121255 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah thanks for pointing that out! I was confused by the fact that we have a NEWS entry in this PR claiming that it fixes the bug. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR amends that news entry. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for a confusion. I was thinking that this pr doesn't deserve a separate news entry. Just a minor cleanup and adds a test. #121255 was a quick fix for annoying issue. FYI: news entry slightly corrected as I've reverted a guard that prevents wiping history file (e.g. if user run readline.clear_history()). Unfortunately, I can't reproduce build failure on "Address sanitizer" job. It looks as |
||
hfile = tempfile.NamedTemporaryFile(delete=False) | ||
hfile.close 8000 () | ||
self.addCleanup(unlink, hfile.name) | ||
env = os.environ.copy() | ||
env.update({"PYTHON_HISTORY": hfile.name}) | ||
commands = "123\nspam\nexit()\n" | ||
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( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
Fix a bug in the handling of the command history of the new :term:`REPL` that caused | ||
the history file to be wiped at REPL exit. | ||
Fix a bug in the handling of the command history of the new :term:`REPL` that | ||
caused the history file to be wiped at REPL exit. ``site.register_readline()`` | ||
helper was refactored to not clear history file if the command history is | ||
empty. Patch by Sergey B Kirpichev. |
Uh oh!
There was an error while loading. Please reload this page.