mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
bpo-40257: Revert changes to inspect.getdoc() (GH-20073)
This commit is contained in:
parent
98e42d1f88
commit
08b47c367a
6 changed files with 115 additions and 40 deletions
|
|
@ -439,7 +439,8 @@ class TestRetrievingSourceCode(GetSourceBase):
|
|||
@unittest.skipIf(sys.flags.optimize >= 2,
|
||||
"Docstrings are omitted with -O2 and above")
|
||||
def test_getdoc_inherited(self):
|
||||
self.assertIsNone(inspect.getdoc(mod.FesteringGob))
|
||||
self.assertEqual(inspect.getdoc(mod.FesteringGob),
|
||||
'A longer,\n\nindented\n\ndocstring.')
|
||||
self.assertEqual(inspect.getdoc(mod.FesteringGob.abuse),
|
||||
'Another\n\ndocstring\n\ncontaining\n\ntabs')
|
||||
self.assertEqual(inspect.getdoc(mod.FesteringGob().abuse),
|
||||
|
|
@ -447,20 +448,10 @@ class TestRetrievingSourceCode(GetSourceBase):
|
|||
self.assertEqual(inspect.getdoc(mod.FesteringGob.contradiction),
|
||||
'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.assertIsNone(finddoc(int))
|
||||
self.assertEqual(finddoc(int), int.__doc__)
|
||||
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__)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue