Skip to content

Commit 074d6c6

Browse files
committed
pythongh-102541: Add test case for Helper.help('module') for non-existent module
1 parent dbefa88 commit 074d6c6

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎Lib/test/test_pydoc.py‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
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, kill_python,
28+
assert_python_failure, spawn_python)
29+
2830
from test.support import threading_helper
2931
from test.support import (reap_children, captured_output, captured_stdout,
3032
captured_stderr, is_emscripten, is_wasi,
@@ -631,6 +633,17 @@ def test_builtin_on_metaclasses(self):
631633
# Testing that the subclasses section does not appear
632634
self.assertNotIn('Built-in subclasses', text)
633635

636+
def test_fail_help_cli(self):
637+
fd, name = tempfile.mkstemp()
638+
self.addCleanup(os_helper.unlink, name)
639+
with open(fd, "w") as f:
640+
f.write("help('abd')")
641+
with spawn_python(name) as proc:
642+
out, _ = proc.communicate()
643+
out = out.decode()
644+
expected = missing_pattern % "abd"
645+
self.assertEqual(expected, out.strip())
646+
634647
def test_fail_help_output_redirect(self):
635648
with StringIO() as buf:
636649
helper = pydoc.Helper(output=buf)

0 commit comments

Comments
 (0)