Test-suite fixes for python -classic
These are mostly workarounds for static class members not being supported for old style classes, as documented in Python.html, "C++ classes".
This commit is contained in:
parent
39a75442a1
commit
76bcec1d87
18 changed files with 118 additions and 41 deletions
|
|
@ -4,6 +4,9 @@ def check(a, b):
|
|||
if a != b:
|
||||
raise RuntimeError(str(a) + " does not equal " + str(b))
|
||||
|
||||
def is_new_style_class(cls):
|
||||
return hasattr(cls, "__class__")
|
||||
|
||||
#### Class ####
|
||||
|
||||
# No implicit conversion
|
||||
|
|
@ -39,13 +42,14 @@ check(2, A_int(1.0).get())
|
|||
check(3, A_int(B()).get())
|
||||
check(4, A_int("hello").get())
|
||||
|
||||
check(1, A_int.sget(1))
|
||||
check(2, A_int.sget(1.0))
|
||||
check(3, A_int.sget(B()))
|
||||
A_int_static = A_int if is_new_style_class(A_int) else A_int(0)
|
||||
check(1, A_int_static.sget(1))
|
||||
check(2, A_int_static.sget(1.0))
|
||||
check(3, A_int_static.sget(B()))
|
||||
|
||||
# explicit constructor:
|
||||
try:
|
||||
check(4, A_int.sget("hello"))
|
||||
check(4, A_int_static.sget("hello"))
|
||||
raise RuntimeError
|
||||
except TypeError:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue