diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-04-15 20:00:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-15 20:00:20 (GMT) |
commit | fbf2786c4c89430e2067016603078cf3500cfe94 (patch) | |
tree | 151141df42e6e058127ef59eae7f95c5e4644991 /Lib/test | |
parent | ba1bcffe5cafc1bb0ac6fdf9ecef51e75e342707 (diff) | |
download | cpython-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')
-rw-r--r-- | Lib/test/test_inspect.py | 15 | ||||
-rw-r--r-- | Lib/test/test_pydoc.py | 3 |
2 files changed, 14 insertions, 4 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__) diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py index ebd8d4a..800913b 100644 --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -1254,7 +1254,8 @@ cm(x) method of builtins.type instance X.attr.__doc__ = 'Custom descriptor' self.assertEqual(self._get_summary_lines(X.attr), """\ -<test.test_pydoc.TestDescriptions.test_custom_non_data_descriptor.<locals>.Descr object>""") +<test.test_pydoc.TestDescriptions.test_custom_non_data_descriptor.<locals>.Descr object> + Custom descriptor""") X.attr.__name__ = 'foo' self.assertEqual(self._get_summary_lines(X.attr), """\ |