|
46 | 46 |
|
47 | 47 | from test.test_inspect import inspect_fodder as mod |
48 | 48 | from test.test_inspect import inspect_fodder2 as mod2 |
| 49 | +from test.test_inspect import inspect_fodder3 as mod3 |
49 | 50 | from test.test_inspect import inspect_stringized_annotations |
50 | 51 | from test.test_inspect import inspect_deferred_annotations |
51 | 52 |
|
@@ -714,6 +715,25 @@ class B(A): |
714 | 715 | b.__doc__ = 'Instance' |
715 | 716 | self.assertEqual(inspect.getdoc(b, fallback_to_class_doc=False), 'Instance') |
716 | 717 |
|
| 718 | + def test_getdoc_inherited_cached_property(self): |
| 719 | + doc = inspect.getdoc(mod3.ParentInheritDoc.foo) |
| 720 | + self.assertEqual(doc, 'docstring for foo defined in parent') |
| 721 | + self.assertEqual(inspect.getdoc(mod3.ChildInheritDoc.foo), doc) |
| 722 | + self.assertEqual(inspect.getdoc(mod3.ChildInheritDefineDoc.foo), doc) |
| 723 | + |
| 724 | + def test_getdoc_redefine_cached_property_as_other(self): |
| 725 | + self.assertEqual(inspect.getdoc(mod3.ChildPropertyFoo.foo), |
| 726 | + 'docstring for the property foo') |
| 727 | + self.assertEqual(inspect.getdoc(mod3.ChildMethodFoo.foo), |
| 728 | + 'docstring for the method foo') |
| 729 | + |
| 730 | + def test_getdoc_define_cached_property(self): |
| 731 | + self.assertEqual(inspect.getdoc(mod3.ChildDefineDoc.foo), |
| 732 | + 'docstring for foo defined in child') |
| 733 | + |
| 734 | + def test_getdoc_nodoc_inherited(self): |
| 735 | + self.assertIsNone(inspect.getdoc(mod3.ChildNoDoc.foo)) |
| 736 | + |
717 | 737 | @unittest.skipIf(MISSING_C_DOCSTRINGS, "test requires docstrings") |
718 | 738 | def test_finddoc(self): |
719 | 739 | finddoc = inspect._finddoc |
|
0 commit comments