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

Method test_issue41287

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

Source from the content-addressed store, hash-verified

362 @unittest.skipIf(sys.flags.optimize >= 2,
363 "Docstrings are omitted with -O2 and above")
364 def test_issue41287(self):
365
366 self.assertEqual(PropertySub.__doc__, "This is a subclass of property",
367 "Docstring of `property` subclass is ignored")
368
369 doc = PropertySub(None, None, None, "issue 41287 is fixed").__doc__
370 self.assertEqual(doc, "issue 41287 is fixed",
371 "Subclasses of `property` ignores `doc` constructor argument")
372
373 def getter(x):
374 """Getter docstring"""
375
376 def getter_wo_doc(x):
377 pass
378
379 for ps in property, PropertySub, PropertySubWoDoc:
380 doc = ps(getter, None, None, "issue 41287 is fixed").__doc__
381 self.assertEqual(doc, "issue 41287 is fixed",
382 "Getter overrides explicit property docstring (%s)" % ps.__name__)
383
384 doc = ps(getter, None, None, None).__doc__
385 self.assertEqual(doc, "Getter docstring", "Getter docstring is not picked-up (%s)" % ps.__name__)
386
387 doc = ps(getter_wo_doc, None, None, "issue 41287 is fixed").__doc__
388 self.assertEqual(doc, "issue 41287 is fixed",
389 "Getter overrides explicit property docstring (%s)" % ps.__name__)
390
391 doc = ps(getter_wo_doc, None, None, None).__doc__
392 self.assertIsNone(doc, "Property class doc appears in instance __doc__ (%s)" % ps.__name__)
393
394 @unittest.skipIf(sys.flags.optimize >= 2,
395 "Docstrings are omitted with -O2 and above")

Callers

nothing calls this directly

Calls 4

psFunction · 0.85
assertIsNoneMethod · 0.80
PropertySubClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected