Skip to content

Commit 46a21f5

Browse files
miss-islingtonEclips4terryjreedy
authored
[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 292ac4b) Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Terry Jan Reedy <[email protected]>
1 parent 139e7ac commit 46a21f5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Lib/test/test_pydoc.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
from urllib.request import urlopen, urlcleanup
2525
from test.support import import_helper
2626
from test.support import os_helper
27-
from test.support.script_helper import assert_python_ok, assert_python_failure
27+
from test.support.script_helper import (assert_python_ok,
28+
assert_python_failure, spawn_python)
2829
from test.support import threading_helper
2930
from test.support import (reap_children, captured_output, captured_stdout,
3031
captured_stderr, is_emscripten, is_wasi,
@@ -631,6 +632,14 @@ def test_builtin_on_metaclasses(self):
631632
# Testing that the subclasses section does not appear
632633
self.assertNotIn('Built-in subclasses', text)
633634

635+
def test_fail_help_cli(self):
636+
elines = (missing_pattern % 'abd').splitlines()
637+
with spawn_python("-c" "help()") as proc:
638+
out, _ = proc.communicate(b"abd")
639+
olines = out.decode().splitlines()[-9:-6]
640+
olines[0] = olines[0].removeprefix('help> ')
641+
self.assertEqual(elines, olines)
642+
634643
def test_fail_help_output_redirect(self):
635644
with StringIO() as buf:
636645
helper = pydoc.Helper(output=buf)

0 commit comments

Comments
 (0)