From bfebb7b54a50f01104f7b6169de77f7fc8feb912 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 15 Dec 2011 15:34:02 -0500 Subject: improve abstract property support (closes #11610) Thanks to Darren Dale for patch. --- Lib/test/test_property.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'Lib/test/test_property.py') diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py index cc6a872179..726d6fee62 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): -- cgit v1.2.1