mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Make “pydoc somebuiltin.somemethod” work (#8887)
This commit is contained in:
parent
158d7696f3
commit
e64e51bfa7
3 changed files with 28 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import sys
|
||||
import builtins
|
||||
import difflib
|
||||
import inspect
|
||||
import pydoc
|
||||
|
@ -419,6 +420,23 @@ class TestDescriptions(unittest.TestCase):
|
|||
expected = 'C in module %s object' % __name__
|
||||
self.assertIn(expected, pydoc.render_doc(c))
|
||||
|
||||
def test_builtin(self):
|
||||
for name in ('str', 'str.translate', 'builtins.str',
|
||||
'builtins.str.translate'):
|
||||
# test low-level function
|
||||
self.assertIsNotNone(pydoc.locate(name))
|
||||
# test high-level function
|
||||
try:
|
||||
pydoc.render_doc(name)
|
||||
except ImportError:
|
||||
self.fail('finding the doc of {!r} failed'.format(o))
|
||||
|
||||
for name in ('notbuiltins', 'strrr', 'strr.translate',
|
||||
'str.trrrranslate', 'builtins.strrr',
|
||||
'builtins.str.trrranslate'):
|
||||
self.assertIsNone(pydoc.locate(name))
|
||||
self.assertRaises(ImportError, pydoc.render_doc, name)
|
||||
|
||||
|
||||
@unittest.skipUnless(threading, 'Threading required for this test.')
|
||||
class PydocServerTest(unittest.TestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue