summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pyrepl/test_pyrepl.py
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2025-01-21 21:04:30 (GMT)
committerGitHub <noreply@github.com>2025-01-21 21:04:30 (GMT)
commit5a9afe23620aadea30013076d64686be8bf66f7e (patch)
tree0e66b1b514c1a8903ad876c688b838ffd76f582e /Lib/test/test_pyrepl/test_pyrepl.py
parentd147e5e52cdb90496ae5fe85b3263cdfa9407a28 (diff)
downloadcpython-5a9afe23620aadea30013076d64686be8bf66f7e.zip
cpython-5a9afe23620aadea30013076d64686be8bf66f7e.tar.gz
cpython-5a9afe23620aadea30013076d64686be8bf66f7e.tar.bz2
gh-123024: Correctly prepare/restore around help and show-history commands (#124485)
Co-authored-by: Emily Morehouse <emily@cuttlesoft.com> Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/test/test_pyrepl/test_pyrepl.py')
-rw-r--r--Lib/test/test_pyrepl/test_pyrepl.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py
index bbe1961..77e1fae 100644
--- a/Lib/test/test_pyrepl/test_pyrepl.py
+++ b/Lib/test/test_pyrepl/test_pyrepl.py
@@ -1343,3 +1343,16 @@ class TestMain(ReplTestCase):
def test_keyboard_interrupt_after_isearch(self):
output, exit_code = self.run_repl(["\x12", "\x03", "exit"])
self.assertEqual(exit_code, 0)
+
+ def test_prompt_after_help(self):
+ output, exit_code = self.run_repl(["help", "q", "exit"])
+
+ # Regex pattern to remove ANSI escape sequences
+ ansi_escape = re.compile(r"(\x1B(=|>|(\[)[0-?]*[ -\/]*[@-~]))")
+ cleaned_output = ansi_escape.sub("", output)
+ self.assertEqual(exit_code, 0)
+
+ # Ensure that we don't see multiple prompts after exiting `help`
+ # Extra stuff (newline and `exit` rewrites) are necessary
+ # because of how run_repl works.
+ self.assertNotIn(">>> \n>>> >>>", cleaned_output)