8000 bpo-41287: Handle `doc` argument of `property.__init__` in subclasses by sizmailov · Pull Request #23205 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-41287: Handle doc argument of property.__init__ in subclasses #23205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
May 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move test to test_property.py
  • Loading branch information
sizmailov committed Apr 5, 2022
commit f09e6acf396c4728cef810a1a675a9d60c0ad2fa
20 changes: 20 additions & 0 deletions Lib/test/test_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,26 @@ def spam(self):
else:
raise Exception("AttributeError not raised")

@unittest.skipIf(sys.flags.optimize >= 2,
"Docstrings are omitted with -O2 and above")
def test_issue41287(self):

self.assertEqual(PropertySub.__doc__, "This is a subclass of property",
"Docstring of `property` subclass is ignored")

doc = PropertySub(None, None, None, "issue 41287 is fixed").__doc__
self.assertEqual(doc, "issue 41287 is fixed",
"Subclasses of `property` ignores `doc` constructor argument")

def getter(x):
"""Getter docstring"""
doc = PropertySub(getter, None, None, "issue 41287 is fixed").__doc__
self.assertEqual(doc, "issue 41287 is fixed",
"Getter overrides explicit property docstring docstring")

doc = PropertySub(getter, None, None, None).__doc__
self.assertEqual(doc, "Getter docstring", "Getter docstring is not picked-up")

@unittest.skipIf(sys.flags.optimize >= 2,
"Docstrings are omitted with -O2 and above")
def test_docstring_copy(self):
Expand Down
19 changes: 0 additions & 19 deletions Lib/test/test_pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,25 +449,6 @@ def test_issue8225(self):
result, doc_loc = get_pydoc_text(xml.etree)
self.assertEqual(doc_loc, "", "MODULE DOCS incorrectly includes a link")

def test_issue41287(self):
# Test issue41287 to ensure property subclass handles `doc` argument correctly

class Property(property):
"""A subclass of builtin property"""

self.assertEqual(Property.__doc__, "A subclass of builtin property", "Docstring of `property` subclass is ignored")

doc = Property(None, None, None, "issue 41287 is fixed").__doc__
self.assertEqual(doc, "issue 41287 is fixed", "Subclasses of `property` ignores `doc` constructor argument")

def getter(x):
"""Getter docstring"""
doc = Property(getter, None, None, "issue 41287 is fixed").__doc__
self.assertEqual(doc, "issue 41287 is fixed", "Getter overrides explicit property docstring docstring")

doc = Property(getter, None, None, None).__doc__
self.assertEqual(doc, "Getter docstring", "Getter docstring is not picked-up")

def test_getpager_with_stdin_none(self):
previous_stdin = sys.stdin
try:
Expand Down
0