summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-07-01 23:16:14 (GMT)
committerGitHub <noreply@github.com>2023-07-01 23:16:14 (GMT)
commit730c873efd9aecbfa2e788faf021a3523ad6a65e (patch)
tree78c78b90fe161d4895d4d07d4f8b7e4d7d788b67 /Lib/test
parent8738c5bceea309944dc4f18e49cf90e871ecbe65 (diff)
downloadcpython-730c873efd9aecbfa2e788faf021a3523ad6a65e.zip
cpython-730c873efd9aecbfa2e788faf021a3523ad6a65e.tar.gz
cpython-730c873efd9aecbfa2e788faf021a3523ad6a65e.tar.bz2
[3.12] gh-102541: Fix Helper.help("mod") for non-existent mod (GH-105934) (#106322)
gh-102541: Fix Helper.help("mod") for non-existent mod (GH-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. --------- (cherry picked from commit 0530f4f64629ff97f3feb7524da0833b9535e8b6) Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru> Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Diffstat (limited to 'Lib/test')
-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