Merged revisions 85154,85182 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r85154 | benjamin.peterson | 2010-10-01 19:03:31 -0500 (Fri, 01 Oct 2010) | 1 line
type.__abstractmethods__ should raise an AttributeError #10006
........
r85182 | benjamin.peterson | 2010-10-02 12:55:47 -0500 (Sat, 02 Oct 2010) | 1 line
add a test and a note about metaclasses now being abcs
........
diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py
index f43123f..0fa40cb 100644
--- a/Lib/test/test_abc.py
+++ b/Lib/test/test_abc.py
@@ -60,6 +60,26 @@
self.assertRaises(TypeError, F) # because bar is abstract now
self.assertTrue(isabstract(F))
+ def test_type_has_no_abstractmethods(self):
+ # type pretends not to have __abstractmethods__.
+ self.assertRaises(AttributeError, getattr, type, "__abstractmethods__")
+ class meta(type):
+ pass
+ self.assertRaises(AttributeError, getattr, meta, "__abstractmethods__")
+
+ def test_metaclass_abc(self):
+ # Metaclasses can be ABCs, too.
+ class A(metaclass=abc.ABCMeta):
+ @abc.abstractmethod
+ def x(self):
+ pass
+ self.assertEqual(A.__abstractmethods__, {"x"})
+ class meta(type, A):
+ def x(self):
+ return 1
+ class C(metaclass=meta):
+ pass
+
def test_registration_basics(self):
class A(metaclass=abc.ABCMeta):
pass