Fix python tests for old versions of Python
This commit is contained in:
parent
76bcec1d87
commit
f1213809a2
6 changed files with 29 additions and 14 deletions
|
|
@ -14,7 +14,7 @@ def is_new_style_class(cls):
|
||||||
|
|
||||||
if not is_new_style_class(A):
|
if not is_new_style_class(A):
|
||||||
# Missing static methods make this hard to test... skip if -classic is used!
|
# Missing static methods make this hard to test... skip if -classic is used!
|
||||||
exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
skip = True # skip builtin check - the autodoc is missing, but it probably should not be
|
skip = True # skip builtin check - the autodoc is missing, but it probably should not be
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,10 @@ def run(module_name):
|
||||||
error = 0
|
error = 0
|
||||||
if error: raise RuntimeError("Foo::meth ignore is not working")
|
if error: raise RuntimeError("Foo::meth ignore is not working")
|
||||||
|
|
||||||
Klass_inc = default_args.Klass.inc if is_new_style_class(default_args.Klass) else default_args.Klass_inc
|
if is_new_style_class(default_args.Klass):
|
||||||
|
Klass_inc = default_args.Klass.inc
|
||||||
|
else:
|
||||||
|
Klass_inc = default_args.Klass_inc
|
||||||
|
|
||||||
if Klass_inc(100, default_args.Klass(22)).val != 122:
|
if Klass_inc(100, default_args.Klass(22)).val != 122:
|
||||||
raise RuntimeError("Klass::inc failed")
|
raise RuntimeError("Klass::inc failed")
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,18 @@ me1 = MyExample1()
|
||||||
if director_abstract.Example1_get_color(me1, 1,2,3) != 1:
|
if director_abstract.Example1_get_color(me1, 1,2,3) != 1:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
MyExample2_static = MyExample2 if is_new_style_class(MyExample2) else MyExample2(0, 0)
|
if is_new_style_class(MyExample2):
|
||||||
|
MyExample2_static = MyExample2
|
||||||
|
else:
|
||||||
|
MyExample2_static = MyExample2(0, 0)
|
||||||
me2 = MyExample2(1,2)
|
me2 = MyExample2(1,2)
|
||||||
if MyExample2_static.get_color(me2, 1,2,3) != 2:
|
if MyExample2_static.get_color(me2, 1,2,3) != 2:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
MyExample3_static = MyExample3 if is_new_style_class(MyExample3) else MyExample3()
|
if is_new_style_class(MyExample3):
|
||||||
|
MyExample3_static = MyExample3
|
||||||
|
else:
|
||||||
|
MyExample3_static = MyExample3()
|
||||||
me3 = MyExample3()
|
me3 = MyExample3()
|
||||||
if MyExample3_static.get_color(me3, 1,2,3) != 3:
|
if MyExample3_static.get_color(me3, 1,2,3) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,10 @@ k5 = Klass5()
|
||||||
k6 = Klass6()
|
k6 = Klass6()
|
||||||
k7 = Klass7()
|
k7 = Klass7()
|
||||||
|
|
||||||
KlassMethods_static = KlassMethods if is_new_style_class(KlassMethods) else KlassMethods()
|
if is_new_style_class(KlassMethods):
|
||||||
|
KlassMethods_static = KlassMethods
|
||||||
|
else:
|
||||||
|
KlassMethods_static = KlassMethods()
|
||||||
KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
|
KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
|
||||||
KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
|
KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
|
||||||
|
|
||||||
|
|
@ -38,10 +40,16 @@ k7 = getKlass7B()
|
||||||
KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
|
KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
|
||||||
KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
|
KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
|
||||||
|
|
||||||
XYZMethods_static = XYZMethods if is_new_style_class(XYZMethods) else XYZMethods()
|
if is_new_style_class(XYZMethods):
|
||||||
|
XYZMethods_static = XYZMethods
|
||||||
|
else:
|
||||||
|
XYZMethods_static = XYZMethods()
|
||||||
XYZMethods_static.methodA(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
|
XYZMethods_static.methodA(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
|
||||||
XYZMethods_static.methodB(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
|
XYZMethods_static.methodB(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
|
||||||
|
|
||||||
TheEnumMethods_static = TheEnumMethods if is_new_style_class(TheEnumMethods) else TheEnumMethods()
|
if is_new_style_class(TheEnumMethods):
|
||||||
|
TheEnumMethods_static = TheEnumMethods
|
||||||
|
else:
|
||||||
|
TheEnumMethods_static = TheEnumMethods()
|
||||||
TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)
|
TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)
|
||||||
TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)
|
TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,10 @@ check(2, A_int(1.0).get())
|
||||||
check(3, A_int(B()).get())
|
check(3, A_int(B()).get())
|
||||||
check(4, A_int("hello").get())
|
check(4, A_int("hello").get())
|
||||||
|
|
||||||
A_int_static = A_int if is_new_style_class(A_int) else A_int(0)
|
if is_new_style_class(A_int):
|
||||||
|
A_int_static = A_int
|
||||||
|
else:
|
||||||
|
A_int_static = A_int(0)
|
||||||
check(1, A_int_static.sget(1))
|
check(1, A_int_static.sget(1))
|
||||||
check(2, A_int_static.sget(1.0))
|
check(2, A_int_static.sget(1.0))
|
||||||
check(3, A_int_static.sget(B()))
|
check(3, A_int_static.sget(B()))
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,6 @@ def failed(a, b, msg):
|
||||||
raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b))
|
raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b))
|
||||||
|
|
||||||
def compare_sequences(a, b):
|
def compare_sequences(a, b):
|
||||||
print("Comparing {} and {}\n".format(a, b))
|
|
||||||
print(" len a: {}\n".format(a.__len__()))
|
|
||||||
print(" len b: {}\n".format(b.__len__()))
|
|
||||||
print(" len a: {}\n".format(type(a.__len__())))
|
|
||||||
print(" len b: {}\n".format(type(b.__len__())))
|
|
||||||
if len(a) != len(b):
|
if len(a) != len(b):
|
||||||
failed(a, b, "different sizes")
|
failed(a, b, "different sizes")
|
||||||
for i in range(len(a)):
|
for i in range(len(a)):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue