[Python-checkins] [3.12] gh-102541: Add test case for help() for non_existent_module (GH-106340) (#106639)

terryjreedy webhook-mailer at python.org
Tue Jul 11 14:35:17 EDT 2023


https://github.com/python/cpython/commit/46a21f5c5e99aa3017618c7bb52d3254a6c0257b
commit: 46a21f5c5e99aa3017618c7bb52d3254a6c0257b
branch: 3.12
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: terryjreedy <tjreedy at udel.edu>
date: 2023-07-11T18:35:13Z
summary:

[3.12] gh-102541: Add test case for help() for non_existent_module (GH-106340) (#106639)

gh-102541: Add test case for help() for non_existent_module (GH-106340)

Test fix for when one enters, for instance, 'abd' at the 'help>' prompt.
---------

(cherry picked from commit 292ac4bfe92768140c2d383fd329cfa1949869b2)

Co-authored-by: Kirill Podoprigora <kirill.bast9 at mail.ru>
Co-authored-by: Terry Jan Reedy <tjreedy at udel.edu>

files:
M Lib/test/test_pydoc.py

diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
index 115ffd3c29d4d..ddb5187f90da9 100644
--- a/Lib/test/test_pydoc.py
+++ b/Lib/test/test_pydoc.py
@@ -24,7 +24,8 @@
 from urllib.request import urlopen, urlcleanup
 from test.support import import_helper
 from test.support import os_helper
-from test.support.script_helper import assert_python_ok, assert_python_failure
+from test.support.script_helper import (assert_python_ok,
+                                        assert_python_failure, spawn_python)
 from test.support import threading_helper
 from test.support import (reap_children, captured_output, captured_stdout,
                           captured_stderr, is_emscripten, is_wasi,
@@ -631,6 +632,14 @@ def test_builtin_on_metaclasses(self):
         # Testing that the subclasses section does not appear
         self.assertNotIn('Built-in subclasses', text)
 
+    def test_fail_help_cli(self):
+        elines = (missing_pattern % 'abd').splitlines()
+        with spawn_python("-c" "help()") as proc:
+            out, _ = proc.communicate(b"abd")
+            olines = out.decode().splitlines()[-9:-6]
+            olines[0] = olines[0].removeprefix('help> ')
+            self.assertEqual(elines, olines)
+
     def test_fail_help_output_redirect(self):
         with StringIO() as buf:
             helper = pydoc.Helper(output=buf)



More information about the Python-checkins mailing list