diff options
author | Raymond Hettinger <python@rcn.com> | 2015-05-13 08:09:59 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-05-13 08:09:59 (GMT) |
commit | eac503aeac6fedc81001b9e1136957d45b9a2c51 (patch) | |
tree | 9b39bdd76843421487a78e56b2eb50c548e47d04 /Lib/test/test_property.py | |
parent | f2244eaf9e3148d6270839e9aa7c2ad9752c17ed (diff) | |
download | cpython-eac503aeac6fedc81001b9e1136957d45b9a2c51.zip cpython-eac503aeac6fedc81001b9e1136957d45b9a2c51.tar.gz cpython-eac503aeac6fedc81001b9e1136957d45b9a2c51.tar.bz2 |
Issue #24064: Property() docstrings are now writeable.
(Patch by Berker Peksag.)
Diffstat (limited to 'Lib/test/test_property.py')
-rw-r--r-- | Lib/test/test_property.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py index e72eb55..5addd36 100644 --- a/Lib/test/test_property.py +++ b/Lib/test/test_property.py @@ -76,6 +76,13 @@ class PropertyNewGetter(object): """new docstring""" return 8 +class PropertyWritableDoc(object): + + @property + def spam(self): + """Eggs""" + return "eggs" + class PropertyTests(unittest.TestCase): def test_property_decorator_baseclass(self): # see #1620 @@ -150,6 +157,21 @@ class PropertyTests(unittest.TestCase): foo = property(foo) C.foo.__isabstractmethod__ + @unittest.skipIf(sys.flags.optimize >= 2, + "Docstrings are omitted with -O2 and above") + def test_property_builtin_doc_writable(self): + p = property(doc='basic') + self.assertEqual(p.__doc__, 'basic') + p.__doc__ = 'extended' + self.assertEqual(p.__doc__, 'extended') + + @unittest.skipIf(sys.flags.optimize >= 2, + "Docstrings are omitted with -O2 and above") + def test_property_decorator_doc_writable(self): + sub = PropertyWritableDoc() + self.assertEqual(sub.__class__.spam.__doc__, 'Eggs') + sub.__class__.spam.__doc__ = 'Spam' + self.assertEqual(sub.__class__.spam.__doc__, 'Spam') # Issue 5890: subclasses of property do not preserve method __doc__ strings class PropertySub(property): |