diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-03 19:38:53 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-03 19:38:53 (GMT) |
commit | 5cf2b7253dc43b203c2f918416b4d25ad1dbfa7d (patch) | |
tree | c12664299b2f9e54eddf21cd3403fcb2daa7fa7f /Lib/test/test_inspect.py | |
parent | 41525e31a5a40c1c20a5115aed9609f49c60b43a (diff) | |
download | cpython-5cf2b7253dc43b203c2f918416b4d25ad1dbfa7d.zip cpython-5cf2b7253dc43b203c2f918416b4d25ad1dbfa7d.tar.gz cpython-5cf2b7253dc43b203c2f918416b4d25ad1dbfa7d.tar.bz2 |
Issue #15582: inspect.getdoc() now follows inheritance chains.
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r-- | Lib/test/test_inspect.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index 401e6cf..2f7e582 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -292,6 +292,27 @@ class TestRetrievingSourceCode(GetSourceBase): self.assertEqual(inspect.getdoc(git.abuse), 'Another\n\ndocstring\n\ncontaining\n\ntabs') + @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.assertEqual(inspect.getdoc(mod.FesteringGob.abuse), + 'Another\n\ndocstring\n\ncontaining\n\ntabs') + self.assertEqual(inspect.getdoc(mod.FesteringGob().abuse), + 'Another\n\ndocstring\n\ncontaining\n\ntabs') + self.assertEqual(inspect.getdoc(mod.FesteringGob.contradiction), + 'The automatic gainsaying.') + + @unittest.skipIf(MISSING_C_DOCSTRINGS, "test requires docstrings") + def test_finddoc(self): + finddoc = inspect._finddoc + 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__) + self.assertEqual(finddoc(int.real), int.real.__doc__) + def test_cleandoc(self): self.assertEqual(inspect.cleandoc('An\n indented\n docstring.'), 'An\nindented\ndocstring.') @@ -316,7 +337,7 @@ class TestRetrievingSourceCode(GetSourceBase): def test_getsource(self): self.assertSourceEqual(git.abuse, 29, 39) - self.assertSourceEqual(mod.StupidGit, 21, 46) + self.assertSourceEqual(mod.StupidGit, 21, 50) def test_getsourcefile(self): self.assertEqual(normcase(inspect.getsourcefile(mod.spam)), modfile) |