Skip to content

Commit

Permalink
pythongh-102541: Add test case for Helper.help('module') for non-ex…
Browse files Browse the repository at this point in the history
…istent module
  • Loading branch information
Eclips4 committed Jul 2, 2023
1 parent dbefa88 commit 074d6c6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Lib/test/test_pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
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, kill_python,
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,
Expand Down Expand Up @@ -631,6 +633,17 @@ 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):
fd, name = tempfile.mkstemp()
self.addCleanup(os_helper.unlink, name)
with open(fd, "w") as f:
f.write("help('abd')")
with spawn_python(name) as proc:
out, _ = proc.communicate()
out = out.decode()
expected = missing_pattern % "abd"
self.assertEqual(expected, out.strip())

def test_fail_help_output_redirect(self):
with StringIO() as buf:
helper = pydoc.Helper(output=buf)
Expand Down

0 comments on commit 074d6c6

Please sign in to comment.