summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_property.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-12-15 20:34:02 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-12-15 20:34:02 (GMT)
commitbfebb7b54a50f01104f7b6169de77f7fc8feb912 (patch)
treeef88caf96404fbb445d25a695eaa8e51bc750566 /Lib/test/test_property.py
parenta8ff01ca7422117dcd906ee2ea55c5293eeceb24 (diff)
downloadcpython-bfebb7b54a50f01104f7b6169de77f7fc8feb912.zip
cpython-bfebb7b54a50f01104f7b6169de77f7fc8feb912.tar.gz
cpython-bfebb7b54a50f01104f7b6169de77f7fc8feb912.tar.bz2
improve abstract property support (closes #11610)
Thanks to Darren Dale for patch.
Diffstat (limited to 'Lib/test/test_property.py')
-rw-r--r--Lib/test/test_property.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py
index cc6a872..726d6fe 100644
--- a/Lib/test/test_property.py
+++ b/Lib/test/test_property.py
@@ -128,6 +128,29 @@ class PropertyTests(unittest.TestCase):
self.assertEqual(newgetter.spam, 8)
self.assertEqual(newgetter.__class__.spam.__doc__, "new docstring")
+ def test_property___isabstractmethod__descriptor(self):
+ for val in (True, False, [], [1], '', '1'):
+ class C(object):
+ def foo(self):
+ pass
+ foo.__isabstractmethod__ = val
+ foo = property(foo)
+ self.assertIs(C.foo.__isabstractmethod__, bool(val))
+
+ # check that the property's __isabstractmethod__ descriptor does the
+ # right thing when presented with a value that fails truth testing:
+ class NotBool(object):
+ def __nonzero__(self):
+ raise ValueError()
+ __len__ = __nonzero__
+ with self.assertRaises(ValueError):
+ class C(object):
+ def foo(self):
+ pass
+ foo.__isabstractmethod__ = NotBool()
+ foo = property(foo)
+ C.foo.__isabstractmethod__
+
# Issue 5890: subclasses of property do not preserve method __doc__ strings
class PropertySub(property):