summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pydoc.py
diff options
context:
space:
mode:
authorKirill Podoprigora <kirill.bast9@mail.ru>2023-07-01 22:46:06 (GMT)
committerGitHub <noreply@github.com>2023-07-01 22:46:06 (GMT)
commit0530f4f64629ff97f3feb7524da0833b9535e8b6 (patch)
treed09678bc0a0c06f6b20640d5372ae89dbd396059 /Lib/test/test_pydoc.py
parent46d77610fc77088bceac720a13d9f2df3a50f29e (diff)
downloadcpython-0530f4f64629ff97f3feb7524da0833b9535e8b6.zip
cpython-0530f4f64629ff97f3feb7524da0833b9535e8b6.tar.gz
cpython-0530f4f64629ff97f3feb7524da0833b9535e8b6.tar.bz2
gh-102541: Fix Helper.help("mod") for non-existent mod (#105934)
If the output arg to Helper() is a stream rather than the default None, which means 'page to stdout', the ImportError from pydoc.resolve is currently not caught in pydoc.doc. The same error is caught when output is None. --------- Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Diffstat (limited to 'Lib/test/test_pydoc.py')
-rw-r--r--Lib/test/test_pydoc.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
index cefc71c..115ffd3 100644
--- a/Lib/test/test_pydoc.py
+++ b/Lib/test/test_pydoc.py
@@ -631,6 +631,13 @@ class PydocDocTest(unittest.TestCase):
# Testing that the subclasses section does not appear
self.assertNotIn('Built-in subclasses', text)
+ def test_fail_help_output_redirect(self):
+ with StringIO() as buf:
+ helper = pydoc.Helper(output=buf)
+ helper.help("abd")
+ expected = missing_pattern % "abd"
+ self.assertEqual(expected, buf.getvalue().strip().replace('\n', os.linesep))
+
@unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(),
'trace function introduces __locals__ unexpectedly')
@requires_docstrings