summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pydoc.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-07-29 15:03:55 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-07-29 15:03:55 (GMT)
commite64e51bfa78cd8ec046e187a3214cd9d477fc65c (patch)
tree176555c53b96a68cccf2d8aac4b00515ec5776d0 /Lib/test/test_pydoc.py
parent158d7696f3da163d0d96321120099456b0545716 (diff)
downloadcpython-e64e51bfa78cd8ec046e187a3214cd9d477fc65c.zip
cpython-e64e51bfa78cd8ec046e187a3214cd9d477fc65c.tar.gz
cpython-e64e51bfa78cd8ec046e187a3214cd9d477fc65c.tar.bz2
Make “pydoc somebuiltin.somemethod” work (#8887)
Diffstat (limited to 'Lib/test/test_pydoc.py')
-rw-r--r--Lib/test/test_pydoc.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
index 2a21a7e..72f5882 100644
--- a/Lib/test/test_pydoc.py
+++ b/Lib/test/test_pydoc.py
@@ -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):