File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # test multiple inheritance of user classes
2+
13class A :
24 def __init__ (self , x ):
35 print ('A init' , x )
@@ -30,6 +32,9 @@ def __init__(self):
3032 def g (self ):
3133 print (self .x )
3234
35+ print (issubclass (Sub , A ))
36+ print (issubclass (Sub , B ))
37+
3338o = Sub ()
3439print (o .x )
3540o .f ()
Original file line number Diff line number Diff line change 1+ # test super with multiple inheritance
2+
3+ class A :
4+ def foo (self ):
5+ print ('A.foo' )
6+
7+ class B :
8+ def foo (self ):
9+ print ('B.foo' )
10+
11+ class C (A , B ):
12+ def foo (self ):
13+ print ('C.foo' )
14+ super ().foo ()
15+
16+ C ().foo ()
Original file line number Diff line number Diff line change 1+ # test sys.getsizeof() function
2+
3+ import sys
4+ try :
5+ sys .getsizeof
6+ except AttributeError :
7+ print ('SKIP' )
8+ raise SystemExit
9+
10+ print (sys .getsizeof ([1 , 2 ]) >= 2 )
11+ print (sys .getsizeof ({1 : 2 }) >= 2 )
12+
13+ class A :
14+ pass
15+ print (sys .getsizeof (A ()) > 0 )
Original file line number Diff line number Diff line change @@ -124,3 +124,18 @@ def f():
124124 f .x = 1
125125except AttributeError :
126126 print ('AttributeError' )
127+
128+ # can't call a function type (ie make new instances of a function)
129+ try :
130+ type (f )()
131+ except TypeError :
132+ print ('TypeError' )
133+
134+ # test when object explicitly listed at not-last position in parent tuple
135+ # this is not compliant with CPython because of illegal MRO
136+ class A :
137+ def foo (self ):
138+ print ('A.foo' )
139+ class B (object , A ):
140+ pass
141+ B ().foo ()
Original file line number Diff line number Diff line change @@ -18,3 +18,5 @@ b'\x01\x02'
1818b'\x01\x00'
1919NotImplementedError
2020AttributeError
21+ TypeError
22+ A.foo
You can’t perform that action at this time.
0 commit comments