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:
William S Fulton 2015-01-31 15:04:35 +00:00
commit 76bcec1d87
18 changed files with 118 additions and 41 deletions

View file

@ -1,5 +1,8 @@
import director_abstract
def is_new_style_class(cls):
return hasattr(cls, "__class__")
class MyFoo(director_abstract.Foo):
def __init__(self):
director_abstract.Foo.__init__(self)
@ -32,12 +35,14 @@ me1 = MyExample1()
if director_abstract.Example1_get_color(me1, 1,2,3) != 1:
raise RuntimeError
MyExample2_static = MyExample2 if is_new_style_class(MyExample2) else MyExample2(0, 0)
me2 = MyExample2(1,2)
if MyExample2.get_color(me2, 1,2,3) != 2:
if MyExample2_static.get_color(me2, 1,2,3) != 2:
raise RuntimeError
MyExample3_static = MyExample3 if is_new_style_class(MyExample3) else MyExample3()
me3 = MyExample3()
if MyExample3.get_color(me3, 1,2,3) != 3:
if MyExample3_static.get_color(me3, 1,2,3) != 3:
raise RuntimeError
error = 1