tests: Add tests to improve coverage of py/objtype.c.

pull/3422/merge
Damien George 2017-12-14 12:25:30 +11:00
rodzic badaf3ecfe
commit 36f79523ab
5 zmienionych plików z 53 dodań i 0 usunięć

Wyświetl plik

@ -1,3 +1,5 @@
# test multiple inheritance of user classes
class A:
def __init__(self, x):
print('A init', x)
@ -30,6 +32,9 @@ class Sub(A, B):
def g(self):
print(self.x)
print(issubclass(Sub, A))
print(issubclass(Sub, B))
o = Sub()
print(o.x)
o.f()

Wyświetl plik

@ -0,0 +1,16 @@
# test super with multiple inheritance
class A:
def foo(self):
print('A.foo')
class B:
def foo(self):
print('B.foo')
class C(A, B):
def foo(self):
print('C.foo')
super().foo()
C().foo()

Wyświetl plik

@ -0,0 +1,15 @@
# test sys.getsizeof() function
import sys
try:
sys.getsizeof
except AttributeError:
print('SKIP')
raise SystemExit
print(sys.getsizeof([1, 2]) >= 2)
print(sys.getsizeof({1: 2}) >= 2)
class A:
pass
print(sys.getsizeof(A()) > 0)

Wyświetl plik

@ -124,3 +124,18 @@ try:
f.x = 1
except AttributeError:
print('AttributeError')
# can't call a function type (ie make new instances of a function)
try:
type(f)()
except TypeError:
print('TypeError')
# test when object explicitly listed at not-last position in parent tuple
# this is not compliant with CPython because of illegal MRO
class A:
def foo(self):
print('A.foo')
class B(object, A):
pass
B().foo()

Wyświetl plik

@ -18,3 +18,5 @@ b'\x01\x02'
b'\x01\x00'
NotImplementedError
AttributeError
TypeError
A.foo