summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/class_inherit_mul.py5
-rw-r--r--tests/basics/class_super_multinherit.py16
-rw-r--r--tests/basics/sys_getsizeof.py15
-rw-r--r--tests/misc/non_compliant.py15
-rw-r--r--tests/misc/non_compliant.py.exp2
5 files changed, 53 insertions, 0 deletions
diff --git a/tests/basics/class_inherit_mul.py b/tests/basics/class_inherit_mul.py
index 23476132ba..4a43a7f410 100644
--- a/tests/basics/class_inherit_mul.py
+++ b/tests/basics/class_inherit_mul.py
@@ -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()
diff --git a/tests/basics/class_super_multinherit.py b/tests/basics/class_super_multinherit.py
new file mode 100644
index 0000000000..642a73ce1a
--- /dev/null
+++ b/tests/basics/class_super_multinherit.py
@@ -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()
diff --git a/tests/basics/sys_getsizeof.py b/tests/basics/sys_getsizeof.py
new file mode 100644
index 0000000000..d16eb1561a
--- /dev/null
+++ b/tests/basics/sys_getsizeof.py
@@ -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)
diff --git a/tests/misc/non_compliant.py b/tests/misc/non_compliant.py
index 152633c3b7..31129f0759 100644
--- a/tests/misc/non_compliant.py
+++ b/tests/misc/non_compliant.py
@@ -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()
diff --git a/tests/misc/non_compliant.py.exp b/tests/misc/non_compliant.py.exp
index 9c157fd5bd..061e3fcc87 100644
--- a/tests/misc/non_compliant.py.exp
+++ b/tests/misc/non_compliant.py.exp
@@ -18,3 +18,5 @@ b'\x01\x02'
b'\x01\x00'
NotImplementedError
AttributeError
+TypeError
+A.foo