summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_abc.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_abc.py')
-rw-r--r--Lib/test/test_abc.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py
index a4cefc5..4965c42 100644
--- a/Lib/test/test_abc.py
+++ b/Lib/test/test_abc.py
@@ -75,15 +75,21 @@ class TestABC(unittest.TestCase):
pass
b = B()
self.assertEqual(issubclass(B, A), False)
+ self.assertEqual(issubclass(B, (A,)), False)
self.assertEqual(isinstance(b, A), False)
+ self.assertEqual(isinstance(b, (A,)), False)
A.register(B)
self.assertEqual(issubclass(B, A), True)
+ self.assertEqual(issubclass(B, (A,)), True)
self.assertEqual(isinstance(b, A), True)
+ self.assertEqual(isinstance(b, (A,)), True)
class C(B):
pass
c = C()
self.assertEqual(issubclass(C, A), True)
+ self.assertEqual(issubclass(C, (A,)), True)
self.assertEqual(isinstance(c, A), True)
+ self.assertEqual(isinstance(c, (A,)), True)
def test_isinstance_invalidation(self):
class A(metaclass=abc.ABCMeta):
@@ -92,22 +98,29 @@ class TestABC(unittest.TestCase):
pass
b = B()
self.assertEqual(isinstance(b, A), False)
+ self.assertEqual(isinstance(b, (A,)), False)
A.register(B)
self.assertEqual(isinstance(b, A), True)
+ self.assertEqual(isinstance(b, (A,)), True)
def test_registration_builtins(self):
class A(metaclass=abc.ABCMeta):
pass
A.register(int)
self.assertEqual(isinstance(42, A), True)
+ self.assertEqual(isinstance(42, (A,)), True)
self.assertEqual(issubclass(int, A), True)
+ self.assertEqual(issubclass(int, (A,)), True)
class B(A):
pass
B.register(str)
class C(str): pass
self.assertEqual(isinstance("", A), True)
+ self.assertEqual(isinstance("", (A,)), True)
self.assertEqual(issubclass(str, A), True)
+ self.assertEqual(issubclass(str, (A,)), True)
self.assertEqual(issubclass(C, A), True)
+ self.assertEqual(issubclass(C, (A,)), True)
def test_registration_edge_cases(self):
class A(metaclass=abc.ABCMeta):
@@ -130,29 +143,40 @@ class TestABC(unittest.TestCase):
class A(metaclass=abc.ABCMeta):
pass
self.failUnless(issubclass(A, A))
+ self.failUnless(issubclass(A, (A,)))
class B(metaclass=abc.ABCMeta):
pass
self.failIf(issubclass(A, B))
+ self.failIf(issubclass(A, (B,)))
self.failIf(issubclass(B, A))
+ self.failIf(issubclass(B, (A,)))
class C(metaclass=abc.ABCMeta):
pass
A.register(B)
class B1(B):
pass
self.failUnless(issubclass(B1, A))
+ self.failUnless(issubclass(B1, (A,)))
class C1(C):
pass
B1.register(C1)
self.failIf(issubclass(C, B))
+ self.failIf(issubclass(C, (B,)))
self.failIf(issubclass(C, B1))
+ self.failIf(issubclass(C, (B1,)))
self.failUnless(issubclass(C1, A))
+ self.failUnless(issubclass(C1, (A,)))
self.failUnless(issubclass(C1, B))
+ self.failUnless(issubclass(C1, (B,)))
self.failUnless(issubclass(C1, B1))
+ self.failUnless(issubclass(C1, (B1,)))
C1.register(int)
class MyInt(int):
pass
self.failUnless(issubclass(MyInt, A))
+ self.failUnless(issubclass(MyInt, (A,)))
self.failUnless(isinstance(42, A))
+ self.failUnless(isinstance(42, (A,)))
def test_all_new_methods_are_called(self):
class A(metaclass=abc.ABCMeta):