summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-02-24 18:03:10 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-02-24 18:03:10 (GMT)
commit6c3787cb70d8efa5f70939a5db300f56a724d698 (patch)
treebab3ed85944db0993682255f1bb751c788f38001 /Lib/test
parent5390d00cc6b99a375140f22e8d75580c1f4cb0a4 (diff)
downloadcpython-6c3787cb70d8efa5f70939a5db300f56a724d698.zip
cpython-6c3787cb70d8efa5f70939a5db300f56a724d698.tar.gz
cpython-6c3787cb70d8efa5f70939a5db300f56a724d698.tar.bz2
Allow usage of SomeABC.register as a class decorator. Patch by Edoardo Spadolini (#10868).
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_abc.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py
index d86f97c..1319a64 100644
--- a/Lib/test/test_abc.py
+++ b/Lib/test/test_abc.py
@@ -121,11 +121,32 @@ class TestABC(unittest.TestCase):
self.assertFalse(issubclass(B, (A,)))
self.assertNotIsInstance(b, A)
self.assertNotIsInstance(b, (A,))
- A.register(B)
+ B1 = A.register(B)
+ self.assertTrue(issubclass(B, A))
+ self.assertTrue(issubclass(B, (A,)))
+ self.assertIsInstance(b, A)
+ self.assertIsInstance(b, (A,))
+ self.assertIs(B1, B)
+ class C(B):
+ pass
+ c = C()
+ self.assertTrue(issubclass(C, A))
+ self.assertTrue(issubclass(C, (A,)))
+ self.assertIsInstance(c, A)
+ self.assertIsInstance(c, (A,))
+
+ def test_register_as_class_deco(self):
+ class A(metaclass=abc.ABCMeta):
+ pass
+ @A.register
+ class B(object):
+ pass
+ b = B()
self.assertTrue(issubclass(B, A))
self.assertTrue(issubclass(B, (A,)))
self.assertIsInstance(b, A)
self.assertIsInstance(b, (A,))
+ @A.register
class C(B):
pass
c = C()
@@ -133,6 +154,7 @@ class TestABC(unittest.TestCase):
self.assertTrue(issubclass(C, (A,)))
self.assertIsInstance(c, A)
self.assertIsInstance(c, (A,))
+ self.assertIs(C, A.register(C))
def test_isinstance_invalidation(self):
class A(metaclass=abc.ABCMeta):