summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pydoc/test_pydoc.py
diff options
context:
space:
mode:
authorEugene Toder <eltoder@users.noreply.github.com>2024-02-20 15:14:34 (GMT)
committerGitHub <noreply@github.com>2024-02-20 15:14:34 (GMT)
commitc0b0c2f2015fb27db4306109b2b3781eb2057c2b (patch)
tree49b34e2f7d762b0abeb3c09e508c8e2fd9255c08 /Lib/test/test_pydoc/test_pydoc.py
parent9af80ec83d1647a472331bd1333a7fa9108fe98e (diff)
downloadcpython-c0b0c2f2015fb27db4306109b2b3781eb2057c2b.zip
cpython-c0b0c2f2015fb27db4306109b2b3781eb2057c2b.tar.gz
cpython-c0b0c2f2015fb27db4306109b2b3781eb2057c2b.tar.bz2
gh-101860: Expose __name__ on property (GH-101876)
Useful for introspection and consistent with functions and other descriptors.
Diffstat (limited to 'Lib/test/test_pydoc/test_pydoc.py')
-rw-r--r--Lib/test/test_pydoc/test_pydoc.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/Lib/test/test_pydoc/test_pydoc.py b/Lib/test/test_pydoc/test_pydoc.py
index d7a333a..b07d911 100644
--- a/Lib/test/test_pydoc/test_pydoc.py
+++ b/Lib/test/test_pydoc/test_pydoc.py
@@ -1162,6 +1162,17 @@ class PydocImportTest(PydocBaseTest):
self.assertEqual(loaded_pydoc.__spec__, pydoc.__spec__)
+class Rect:
+ @property
+ def area(self):
+ '''Area of the rect'''
+ return self.w * self.h
+
+
+class Square(Rect):
+ area = property(lambda self: self.side**2)
+
+
class TestDescriptions(unittest.TestCase):
def test_module(self):
@@ -1550,13 +1561,13 @@ cm(x) class method of test.test_pydoc.test_pydoc.X
@requires_docstrings
def test_property(self):
- class Rect:
- @property
- def area(self):
- '''Area of the rect'''
- return self.w * self.h
-
self.assertEqual(self._get_summary_lines(Rect.area), """\
+area
+ Area of the rect
+""")
+ # inherits the docstring from Rect.area
+ self.assertEqual(self._get_summary_lines(Square.area), """\
+area
Area of the rect
""")
self.assertIn("""