MCPcopy Create free account
hub / github.com/python/cpython / test_prefer_explicit_doc

Method test_prefer_explicit_doc

Lib/test/test_property.py:468–486  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

466 @unittest.skipIf(sys.flags.optimize >= 2,
467 "Docstrings are omitted with -O2 and above")
468 def test_prefer_explicit_doc(self):
469 # Issue 25757: subclasses of property lose docstring
470 self.assertEqual(property(doc="explicit doc").__doc__, "explicit doc")
471 self.assertEqual(PropertySub(doc="explicit doc").__doc__, "explicit doc")
472
473 class Foo:
474 spam = PropertySub(doc="spam explicit doc")
475
476 @spam.getter
477 def spam(self):
478 """ignored as doc already set"""
479 return 1
480
481 def _stuff_getter(self):
482 """ignored as doc set directly"""
483 stuff = PropertySub(doc="stuff doc argument", fget=_stuff_getter)
484
485 #self.assertEqual(Foo.spam.__doc__, "spam explicit doc")
486 self.assertEqual(Foo.stuff.__doc__, "stuff doc argument")
487
488 def test_property_no_doc_on_getter(self):
489 # If a property's getter has no __doc__ then the property's doc should

Callers

nothing calls this directly

Calls 3

propertyClass · 0.85
PropertySubClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected