Backport of _abccoll.py by Benjamin Arangueren, issue 1383.

With some changes of my own thrown in (e.g. backport of r58107).
This commit is contained in:
Guido van Rossum 2007-11-22 00:55:51 +00:00
parent cc7f26bf20
commit 64c06e327d
13 changed files with 822 additions and 51 deletions

View file

@ -133,6 +133,20 @@ class TestABC(unittest.TestCase):
self.failUnless(issubclass(MyInt, A))
self.failUnless(isinstance(42, A))
def test_all_new_methods_are_called(self):
class A:
__metaclass__ = abc.ABCMeta
class B:
counter = 0
def __new__(cls):
B.counter += 1
return super(B, cls).__new__(cls)
class C(A, B):
pass
self.assertEqual(B.counter, 0)
C()
self.assertEqual(B.counter, 1)
def test_main():
test_support.run_unittest(TestABC)