summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-04-15 20:00:20 (GMT)
committerGitHub <noreply@github.com>2020-04-15 20:00:20 (GMT)
commitfbf2786c4c89430e2067016603078cf3500cfe94 (patch)
tree151141df42e6e058127ef59eae7f95c5e4644991 /Lib/test/test_inspect.py
parentba1bcffe5cafc1bb0ac6fdf9ecef51e75e342707 (diff)
downloadcpython-fbf2786c4c89430e2067016603078cf3500cfe94.zip
cpython-fbf2786c4c89430e2067016603078cf3500cfe94.tar.gz
cpython-fbf2786c4c89430e2067016603078cf3500cfe94.tar.bz2
bpo-40257: Output object's own docstring in pydoc (GH-19479)
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index f193807..2dc8454 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -439,8 +439,7 @@ class TestRetrievingSourceCode(GetSourceBase):
@unittest.skipIf(sys.flags.optimize >= 2,
"Docstrings are omitted with -O2 and above")
def test_getdoc_inherited(self):
- self.assertEqual(inspect.getdoc(mod.FesteringGob),
- 'A longer,\n\nindented\n\ndocstring.')
+ self.assertIsNone(inspect.getdoc(mod.FesteringGob))
self.assertEqual(inspect.getdoc(mod.FesteringGob.abuse),
'Another\n\ndocstring\n\ncontaining\n\ntabs')
self.assertEqual(inspect.getdoc(mod.FesteringGob().abuse),
@@ -449,9 +448,19 @@ class TestRetrievingSourceCode(GetSourceBase):
'The automatic gainsaying.')
@unittest.skipIf(MISSING_C_DOCSTRINGS, "test requires docstrings")
+ def test_getowndoc(self):
+ getowndoc = inspect._getowndoc
+ self.assertEqual(getowndoc(type), type.__doc__)
+ self.assertEqual(getowndoc(int), int.__doc__)
+ self.assertEqual(getowndoc(int.to_bytes), int.to_bytes.__doc__)
+ self.assertEqual(getowndoc(int().to_bytes), int.to_bytes.__doc__)
+ self.assertEqual(getowndoc(int.from_bytes), int.from_bytes.__doc__)
+ self.assertEqual(getowndoc(int.real), int.real.__doc__)
+
+ @unittest.skipIf(MISSING_C_DOCSTRINGS, "test requires docstrings")
def test_finddoc(self):
finddoc = inspect._finddoc
- self.assertEqual(finddoc(int), int.__doc__)
+ self.assertIsNone(finddoc(int))
self.assertEqual(finddoc(int.to_bytes), int.to_bytes.__doc__)
self.assertEqual(finddoc(int().to_bytes), int.to_bytes.__doc__)
self.assertEqual(finddoc(int.from_bytes), int.from_bytes.__doc__)