mirror of
https://github.com/python/cpython.git
synced 2025-11-25 12:44:13 +00:00
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:
parent
cc7f26bf20
commit
64c06e327d
13 changed files with 822 additions and 51 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue