Remove print statements from Python tests

Use exceptions instead of printing to stdout.
Part of an effort to convert Python tests to python 3 syntax.
This commit is contained in:
William S Fulton 2020-08-13 21:22:47 +01:00
parent e535190c34
commit 365d4961d4
40 changed files with 123 additions and 254 deletions

View File

@ -6,7 +6,6 @@ if mainc(largs) != 3:
targs = ("hi", "hola")
if mainv(targs, 1) != "hola":
print(mainv(targs, 1))
raise RuntimeError("bad main typemap")
targs = ("hi", "hola")

View File

@ -2,11 +2,9 @@ from char_binary import *
t = Test()
if t.strlen("hile") != 4:
print t.strlen("hile")
raise RuntimeError, "bad multi-arg typemap"
raise RuntimeError("bad multi-arg typemap {}".format(t.strlen("hile")))
if t.ustrlen("hile") != 4:
print t.ustrlen("hile")
raise RuntimeError, "bad multi-arg typemap"
raise RuntimeError("bad multi-arg typemap {}".format(t.ustrlen("hile")))
if t.strlen("hil\0") != 4:
raise RuntimeError, "bad multi-arg typemap"
@ -31,8 +29,7 @@ if t.ustrlen(pc) != 4:
cvar.var_pchar = pc
if cvar.var_pchar != "hola":
print cvar.var_pchar
raise RuntimeError, "bad pointer case"
raise RuntimeError("bad pointer case {}".format(cvar.var_pchar))
cvar.var_namet = pc
# if cvar.var_namet != "hola\0":

View File

@ -4,33 +4,26 @@ error = 0
p = constover.test("test")
if p != "test":
print "test failed!"
error = 1
raise RuntimeError("test failed!")
p = constover.test_pconst("test")
if p != "test_pconst":
print "test_pconst failed!"
error = 1
raise RuntimeError("test_pconst failed!")
f = constover.Foo()
p = f.test("test")
if p != "test":
print "member-test failed!"
error = 1
raise RuntimeError("member-test failed!")
p = f.test_pconst("test")
if p != "test_pconst":
print "member-test_pconst failed!"
error = 1
raise RuntimeError("member-test_pconst failed!")
p = f.test_constm("test")
if p != "test_constmethod":
print "member-test_constm failed!"
error = 1
raise RuntimeError("member-test_constm failed!")
p = f.test_pconstm("test")
if p != "test_pconstmethod":
print "member-test_pconstm failed!"
error = 1
raise RuntimeError("member-test_pconstm failed!")
sys.exit(error)

View File

@ -3,21 +3,17 @@ import cpp_enum
f = cpp_enum.Foo()
if f.hola != f.Hello:
print f.hola
raise RuntimeError
raise RuntimeError("f.hola: {}".format(f.hola))
f.hola = f.Hi
if f.hola != f.Hi:
print f.hola
raise RuntimeError
raise RuntimeError("f.hola: {}".format(f.hola))
f.hola = f.Hello
if f.hola != f.Hello:
print f.hola
raise RuntimeError
raise RuntimeError("f.hola: {}".format(f.hola))
cpp_enum.cvar.hi = cpp_enum.Hello
if cpp_enum.cvar.hi != cpp_enum.Hello:
print cpp_enum.cvar.hi
raise RuntimeError
raise RuntimeError("cpp_enum.cvar.hi: {}".format(cpp_enum.cvar.hi))

View File

@ -108,48 +108,34 @@ def run(module_name):
if Klass_inc().val != 0:
raise RuntimeError("Klass::inc failed")
tricky_failure = False
tricky = default_args.TrickyInPython()
if tricky.value_m1(10) != -1:
print "trickyvalue_m1 failed"
tricky_failure = True
raise RuntimeError("trickyvalue_m1 failed")
if tricky.value_m1(10, 10) != 10:
print "trickyvalue_m1 failed"
tricky_failure = True
raise RuntimeError("trickyvalue_m1 failed")
if tricky.value_0xabcdef(10) != 0xabcdef:
print "trickyvalue_0xabcdef failed"
tricky_failure = True
raise RuntimeError("trickyvalue_0xabcdef failed")
if tricky.value_0644(10) != 420:
print "trickyvalue_0644 failed"
tricky_failure = True
raise RuntimeError("trickyvalue_0644 failed")
if tricky.value_perm(10) != 420:
print "trickyvalue_perm failed"
tricky_failure = True
raise RuntimeError("trickyvalue_perm failed")
if tricky.value_m01(10) != -1:
print "trickyvalue_m01 failed"
tricky_failure = True
raise RuntimeError("trickyvalue_m01 failed")
if not tricky.booltest2():
print "booltest2 failed"
tricky_failure = True
raise RuntimeError("booltest2 failed")
if tricky.max_32bit_int1() != 0x7FFFFFFF:
print "max_32bit_int1 failed"
tricky_failure = True
raise RuntimeError("max_32bit_int1 failed")
if tricky.min_32bit_int1() != -2147483648:
print "min_32bit_int1 failed"
tricky_failure = True
raise RuntimeError("min_32bit_int1 failed")
if tricky.max_32bit_int2() != 0x7FFFFFFF:
print "max_32bit_int2 failed"
tricky_failure = True
raise RuntimeError("max_32bit_int2 failed")
tricky.too_big_32bit_int1()
tricky.too_small_32bit_int1()
tricky.too_big_32bit_int2()
tricky.too_small_32bit_int2()
if tricky_failure:
raise RuntimeError
default_args.seek()
default_args.seek(10)

View File

@ -34,68 +34,48 @@ class MyFoo4(Foo):
# Check that the NotImplementedError raised by MyFoo.ping() is returned by
# MyFoo.pong().
ok = 0
a = MyFoo()
b = launder(a)
try:
b.pong()
except NotImplementedError, e:
if str(e) == "MyFoo::ping() EXCEPTION":
ok = 1
else:
print "Unexpected error message: %s" % str(e)
except:
if not str(e) == "MyFoo::ping() EXCEPTION":
raise RuntimeError("Unexpected error message: %s" % str(e))
except TypeError:
pass
if not ok:
raise RuntimeError
# Check that the director returns the appropriate TypeError if the return type
# is wrong.
ok = 0
a = MyFoo2()
b = launder(a)
try:
b.pong()
except TypeError, e:
# fastdispatch mode adds on Additional Information to the exception message - just check the main exception message exists
if str(e).startswith("SWIG director type mismatch in output value of type 'std::string'"):
ok = 1
else:
print "Unexpected error message: %s" % str(e)
if not ok:
raise RuntimeError
if not str(e).startswith("SWIG director type mismatch in output value of type 'std::string'"):
raise RuntimeError("Unexpected error message: %s" % str(e))
# Check that the director can return an exception which requires two arguments
# to the constructor, without mangling it.
ok = 0
a = MyFoo3()
b = launder(a)
try:
b.pong()
except MyException, e:
if e.msg == "foobar":
ok = 1
else:
print "Unexpected error message: %s" % str(e)
if not ok:
raise RuntimeError
if e.msg != "foobar":
raise RuntimeError("Unexpected error message: %s" % str(e))
# Check that the director returns the appropriate TypeError thrown in a director method
ok = 0
a = MyFoo4()
b = launder(a)
try:
b.pong()
except TypeError as e:
if str(e).startswith("type() takes 1 or 3 arguments"):
ok = 1
else:
print "Unexpected error message: %s" % str(e)
if not ok:
raise RuntimeError
if not str(e).startswith("type() takes 1 or 3 arguments"):
raise RuntimeError("Unexpected error message: %s" % str(e))
# This is expected to fail with -builtin option

View File

@ -38,4 +38,4 @@ while i:
a = fi(a) # 20
i -= 1
print a
print("a: {}".format(a))

View File

@ -18,12 +18,10 @@ b = B("hello")
b.get(0)
if b.get_first() != "hello world!":
print b.get_first()
raise RuntimeError
raise RuntimeError("b.get_first(): {}".format(b.get_first()))
b.call_process_func()
if b.smem != "hello":
print smem
raise RuntimeError
raise RuntimeError("smem: {}".format(smem))

View File

@ -14,7 +14,6 @@ d = Derived()
d.run()
if d.val >= 0:
print d.val
raise RuntimeError
raise RuntimeError("d.val: {}".format(d.val))
d.stop()

View File

@ -16,5 +16,4 @@ c = b.get()
if not (a.this == c.this):
print a, c
raise RuntimeError
raise RuntimeError("{} {}".format(a, c))

View File

@ -17,12 +17,10 @@ b = B(u"hello")
b.get(0)
if b.get_first() != u"hello world!":
print b.get_first()
raise RuntimeError
raise RuntimeError("b.get_first(): {}".format(b.get_first()))
b.call_process_func()
if b.smem != u"hello":
print smem
raise RuntimeError
raise RuntimeError("smem: {}".format(smem))

View File

@ -8,4 +8,4 @@ y = b.blah()
a = dynamic_cast.do_test(y)
if a != "Bar::test":
print "Failed!!"
raise RuntimeError("Failed!!")

View File

@ -25,8 +25,7 @@ try:
a.foobar()
except RuntimeError, e:
if e.args[0] != "postcatch unknown":
print "bad exception order",
raise RuntimeError, e.args
raise RuntimeError("bad exception order {}".format(e.args))
try:

View File

@ -1,31 +1,21 @@
import inctest
error = 0
try:
a = inctest.A()
except:
print "didn't find A"
print "therefore, I didn't include 'testdir/subdir1/hello.i'"
error = 1
raise RuntimeError("didn't find A, therefore, I didn't include 'testdir/subdir1/hello.i'")
pass
try:
b = inctest.B()
except:
print "didn't find B"
print "therefore, I didn't include 'testdir/subdir2/hello.i'"
error = 1
raise RuntimeError("didn't find B, therefore, I didn't include 'testdir/subdir2/hello.i'")
pass
if error == 1:
raise RuntimeError
# Check the import in subdirectory worked
if inctest.importtest1(5) != 15:
print "import test 1 failed"
raise RuntimeError
raise RuntimeError("import test 1 failed")
if inctest.importtest2("black") != "white":
print "import test 2 failed"
raise RuntimeError
raise RuntimeError("import test 2 failed")

View File

@ -6,14 +6,14 @@ c = inherit_missing.Spam()
x = inherit_missing.do_blah(a)
if x != "Foo::blah":
print "Whoa! Bad return", x
raise RuntimeError("Whoa! Bad return {}".format(x))
x = inherit_missing.do_blah(b)
if x != "Bar::blah":
print "Whoa! Bad return", x
raise RuntimeError("Whoa! Bad return {}".format(x))
x = inherit_missing.do_blah(c)
if x != "Spam::blah":
print "Whoa! Bad return", x
raise RuntimeError("Whoa! Bad return {}".format(x))
inherit_missing.delete_Foo(a)

View File

@ -3,8 +3,7 @@ a = inplaceadd.A(7)
a += 5
if a.val != 12:
print a.val
raise RuntimeError
raise RuntimeError("a.val: {}".format(a.val))
a -= 5
if a.val != 7:

View File

@ -8,12 +8,10 @@ if aa.a != 1:
raise RuntimeError
aa.a = 3
if aa.a != 3:
print aa.a
raise RuntimeError
raise RuntimeError("aa.a: {}".format(aa.a))
if aa.b != 2:
print aa.b
raise RuntimeError
raise RuntimeError("aa.b: {}".format(aa.b))
aa.b = 5
if aa.b != 5:
raise RuntimeError

View File

@ -7,8 +7,7 @@ chell = li_attribute_template.Cintint(1, 2, 3)
def rassert(what, master):
if what != master:
print what
raise RuntimeError
raise RuntimeError("what: {}".format(what))
# Testing primitive by value attribute
rassert(chell.a, 1)

View File

@ -11,12 +11,10 @@ if test2() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^
raise RuntimeError
if test3("hello") != "hello-suffix":
print test3("hello")
raise RuntimeError
raise RuntimeError("test3(\"hello\")")
if test4("hello") != "hello-suffix":
print test4("hello")
raise RuntimeError
raise RuntimeError("test4(\"hello\")")
if test5(4) != "xxxx":
raise RuntimeError

View File

@ -25,8 +25,7 @@ for k in m:
for k in m:
if pm[k].this != m[k].this:
print pm[k], m[k]
raise RuntimeError
raise RuntimeError("Not equal {} {}".format(pm[k], m[k]))
m = {}

View File

@ -9,5 +9,4 @@ o << a << " " << 2345 << " " << 1.435
if o.str() != "A class 2345 1.435":
print "\"%s\"" % (o.str(),)
raise RuntimeError
raise RuntimeError("str failed: \"%s\"".format(o.str()))

View File

@ -10,8 +10,7 @@ if li_std_string_extra.test_cvalue(x) != x:
raise RuntimeError, "bad string mapping"
if li_std_string_extra.test_value(x) != x:
print x, li_std_string_extra.test_value(x)
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping {} {}".format(x, li_std_string_extra.test_value(x)))
if li_std_string_extra.test_const_reference(x) != x:
raise RuntimeError, "bad string mapping"
@ -23,8 +22,7 @@ s = li_std_string_extra.string("he")
s = s + "llo"
if s != x:
print s, x
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping {} {}".format(s, x))
if s[1:4] != x[1:4]:
raise RuntimeError, "bad string mapping"
@ -47,8 +45,7 @@ b = li_std_string_extra.string(" world")
s = a + b
if a + b != "hello world":
print a + b
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping {}".format(a + b))
if a + " world" != "hello world":
raise RuntimeError, "bad string mapping"

View File

@ -8,5 +8,4 @@ o = wostringstream()
o << a << u" " << 2345 << u" " << 1.435 << wends
if o.str() != "A class 2345 1.435\0":
print "\"%s\"" % (o.str(),)
raise RuntimeError
raise RuntimeError("str failed: \"%s\"".format(o.str()))

View File

@ -7,8 +7,7 @@ s = li_std_wstring_inherit.wstring(u"he")
s = s + u"llo"
if s != x:
print s, x
raise RuntimeError("bad string mapping")
raise RuntimeError("bad string mapping {} {}".format(s, x))
if s[1:4] != x[1:4]:
raise RuntimeError("bad string mapping")

View File

@ -31,8 +31,7 @@ v_check()
def pyerror(name, val, cte):
print "bad val/cte", name, val, cte
raise RuntimeError
raise RuntimeError("bad val/cte {} {} {}".format(name, val, cte))
pass
if cvar.var_bool != cct_bool:
@ -228,26 +227,22 @@ t.v_check()
# this value contains a '0' char!
if def_namet != "hola":
print "bad namet", def_namet
raise RuntimeError
raise RuntimeError("bad namet {}".format(def_namet))
t.var_namet = def_namet
if t.var_namet != def_namet:
print "bad namet", t.var_namet, def_namet
raise RuntimeError
raise RuntimeError("bad namet {} {}".format(t.var_namet, def_namet))
t.var_namet = "hola"
if t.var_namet != "hola":
print "bad namet", t.var_namet
raise RuntimeError
raise RuntimeError("bad namet {}".format(t.var_namet))
t.var_namet = "hol"
if t.var_namet != "hol":
# if t.var_namet != "hol\0\0":
print "bad namet", t.var_namet
raise RuntimeError
raise RuntimeError("bad namet {}".format(t.var_namet))
cvar.var_char = "\0"
@ -261,8 +256,7 @@ if cvar.var_char != "\0":
cvar.var_namet = "\0"
# if cvar.var_namet != "\0\0\0\0\0":
if cvar.var_namet != "":
print "hola", "", cvar.var_namet
raise RuntimeError, "bad char '\0' case"
raise RuntimeError("bad char '\0' case hola {}".format(cvar.var_namet))
cvar.var_namet = ""
# if cvar.var_namet != "\0\0\0\0\0":
@ -275,8 +269,7 @@ if cvar.var_pchar != None:
cvar.var_pchar = ""
if cvar.var_pchar != "":
print "%c" % (cvar.var_pchar[0],)
raise RuntimeError, "bad char empty case"
raise RuntimeError("bad char empty case %c" % (cvar.var_pchar[0],))
cvar.var_pcharc = None
if cvar.var_pcharc != None:
@ -300,8 +293,7 @@ pchar_setitem(pc, 4, 0)
cvar.var_pchar = pc
if cvar.var_pchar != "hola":
print cvar.var_pchar
raise RuntimeError, "bad pointer case"
raise RuntimeError("bad pointer case {}".format(cvar.var_pchar))
cvar.var_namet = pc
# if cvar.var_namet != "hola\0":

View File

@ -51,9 +51,7 @@ if python_nondynamic.retrieve_A_b(bb) != 5: raise RuntimeError("b not set correc
try:
bb.c = 3
print("bb.c = {}".format(bb.c))
print("B.c = {}".format(B.c))
raise RuntimeError("B.c class variable messes up nondynamic-ness of B")
raise RuntimeError("B.c class variable messes up nondynamic-ness of B bb.c={} B.c={}".format(bb.c, B.c))
except AttributeError as e:
debug_print(e)
pass
@ -99,9 +97,7 @@ if is_python_modern() and not python_nondynamic.is_python_builtin():
if not python_nondynamic.is_python_builtin():
try:
bb.cc = 3
print("bb.cc = {}".format(bb.cc))
print("B.cc = {}".format(B.cc))
raise RuntimeError("B.cc class variable messes up nondynamic-ness of B")
raise RuntimeError("B.cc class variable messes up nondynamic-ness of B bb.cc={} B.cc={}".format(bb.cc, B.cc))
except AttributeError as e:
debug_print(e)
pass

View File

@ -15,15 +15,15 @@ check(p)
r = p.__reduce__()
if python_pickle.cvar.debug:
print "__reduce__ returned:", r
print("__reduce__ returned: {}".format(r))
pickle_string = pickle.dumps(p)
newp = pickle.loads(pickle_string)
check(newp)
# Not yet working... some crash and others are not producing a sensible "can't be pickled" error
#nfp = python_pickle.NotForPickling("no no")
#print nfp.__reduce__()
#print("{}".format(nfp.__reduce__()))
#pickle_string = pickle.dumps(nfp)
#print pickle_string
#print("{}".format(pickle_string))
#newp = pickle.loads(pickle_string)
#print newp.msg
#print("{}".format(newp.msg))

View File

@ -17,13 +17,13 @@ if len(sys.argv) >= 2 and sys.argv[1] == "benchmark":
a = bytearray(b"hello world")
for i in range(k):
python_pybuffer.title1(a)
print "Time used by bytearray:", time.time() - t
print("Time used by bytearray: {}".format(time.time() - t))
t = time.time()
b = "hello world"
for i in range(k):
python_pybuffer.title2(b)
print "Time used by string:", time.time() - t
print("Time used by string: {}".format(time.time() - t))
else:
# run the test case
buf1 = bytearray(10)

View File

@ -3,10 +3,8 @@ import sys
p = return_const_value.Foo_ptr_getPtr()
if (p.getVal() != 17):
print "Runtime test1 failed. p.getVal()=", p.getVal()
sys.exit(1)
raise RuntimeError("Runtime test1 failed. p.getVal()={}".format(p.getVal()))
p = return_const_value.Foo_ptr_getConstPtr()
if (p.getVal() != 17):
print "Runtime test2 failed. p.getVal()=", p.getVal()
sys.exit(1)
raise RuntimeError("Runtime test2 failed. p.getVal()={}".format(p.getVal()))

View File

@ -11,9 +11,7 @@ b = Bar(f)
b.y = 2
if f.y != 2:
print f.y
print b.y
raise RuntimeError
raise RuntimeError("Failed {} {}".format(f.y, b.y))
if b.x != f.x:
raise RuntimeError

View File

@ -33,8 +33,7 @@ if vu[2] != std_containers.videntu(vu)[2]:
if v[0:3][1] != vu[0:3][1]:
print v[0:3][1], vu[0:3][1]
raise RuntimeError, "bad getslice"
raise RuntimeError("bad getslice {} {}".format(v[0:3][1], vu[0:3][1]))
m = ((1, 2, 3), (2, 3), (3, 4))

View File

@ -23,8 +23,7 @@ xstr2 = str.lstrip(xstr2, "0")
xstr2 = str.upper(xstr2)
if xstr1 != xstr2:
print xstr1, xstr2
raise RuntimeError
raise RuntimeError("Not equal failed {} {}".format(xstr1, xstr2))
s = str(a.this)
r = repr(a.this)

View File

@ -8,25 +8,21 @@ try:
d = make_Identity_double()
a = d.this
except:
print d, "is not an instance"
raise RuntimeError
raise RuntimeError("{} is not an instance".format(d))
s = "%s" % d
if str.find(s, "ArithUnaryFunction") == -1:
print d, "is not an ArithUnaryFunction"
raise RuntimeError
raise RuntimeError("{} is not an ArithUnaryFunction".format(d))
try:
e = make_Multiplies_double_double_double_double(d, d)
a = e.this
except:
print e, "is not an instance"
raise RuntimeError
raise RuntimeError("{} is not an instance".format(e))
s = "%s" % e
if str.find(s, "ArithUnaryFunction") == -1:
print e, "is not an ArithUnaryFunction"
raise RuntimeError
raise RuntimeError("{} is not an ArithUnaryFunction".format(e))
#
@ -37,25 +33,21 @@ try:
c = make_Identity_complex()
a = c.this
except:
print c, "is not an instance"
raise RuntimeError
raise RuntimeError("{} is not an instance".format(c))
s = "%s" % c
if str.find(s, "ArithUnaryFunction") == -1:
print c, "is not an ArithUnaryFunction"
raise RuntimeError
raise RuntimeError("{} is not an ArithUnaryFunction".format(c))
try:
f = make_Multiplies_complex_complex_complex_complex(c, c)
a = f.this
except:
print f, "is not an instance"
raise RuntimeError
raise RuntimeError("{} is not an instance".format(f))
s = "%s" % f
if str.find(s, "ArithUnaryFunction") == -1:
print f, "is not an ArithUnaryFunction"
raise RuntimeError
raise RuntimeError("{} is not an ArithUnaryFunction".format(f))
#
# Mix case
@ -65,29 +57,24 @@ try:
g = make_Multiplies_double_double_complex_complex(d, c)
a = g.this
except:
print g, "is not an instance"
raise RuntimeError
raise RuntimeError("{} is not an instance".format(g))
s = "%s" % g
if str.find(s, "ArithUnaryFunction") == -1:
print g, "is not an ArithUnaryFunction"
raise RuntimeError
raise RuntimeError("{} is not an ArithUnaryFunction".format(g))
try:
h = make_Multiplies_complex_complex_double_double(c, d)
a = h.this
except:
print h, "is not an instance"
raise RuntimeError
raise RuntimeError("{} is not an instance".format(h))
s = "%s" % h
if str.find(s, "ArithUnaryFunction") == -1:
print h, "is not an ArithUnaryFunction"
raise RuntimeError
raise RuntimeError("{} is not an ArithUnaryFunction".format(h))
try:
a = g.get_value()
except:
print g, "has not get_value() method"
raise RuntimeError
raise RuntimeError("{}, has not get_value() method".format(g))

View File

@ -8,25 +8,21 @@ try:
d = make_Identity_double()
a = d.this
except:
print d, "is not an instance"
raise RuntimeError
raise RuntimeError("{} is not an instance".format(d))
s = "%s" % d
if str.find(s, "ArithUnaryFunction") == -1:
print d, "is not an ArithUnaryFunction"
raise RuntimeError
raise RuntimeError("{} is not an ArithUnaryFunction".format(d))
try:
e = make_Multiplies_double_double_double_double(d, d)
a = e.this
except:
print e, "is not an instance"
raise RuntimeError
raise RuntimeError("{} is not an instance".format(e))
s = "%s" % e
if str.find(s, "ArithUnaryFunction") == -1:
print e, "is not an ArithUnaryFunction"
raise RuntimeError
raise RuntimeError("{} is not an ArithUnaryFunction".format(e))
#
@ -37,25 +33,21 @@ try:
c = make_Identity_complex()
a = c.this
except:
print c, "is not an instance"
raise RuntimeError
raise RuntimeError("{} is not an instance".format(c))
s = "%s" % c
if str.find(s, "ArithUnaryFunction") == -1:
print c, "is not an ArithUnaryFunction"
raise RuntimeError
raise RuntimeError("{} is not an ArithUnaryFunction".format(c))
try:
f = make_Multiplies_complex_complex_complex_complex(c, c)
a = f.this
except:
print f, "is not an instance"
raise RuntimeError
raise RuntimeError("{} is not an instance".format(f))
s = "%s" % f
if str.find(s, "ArithUnaryFunction") == -1:
print f, "is not an ArithUnaryFunction"
raise RuntimeError
raise RuntimeError("{} is not an ArithUnaryFunction".format(f))
#
# Mix case
@ -65,23 +57,19 @@ try:
g = make_Multiplies_double_double_complex_complex(d, c)
a = g.this
except:
print g, "is not an instance"
raise RuntimeError
raise RuntimeError("{} is not an instance".format(g))
s = "%s" % g
if str.find(s, "ArithUnaryFunction") == -1:
print g, "is not an ArithUnaryFunction"
raise RuntimeError
raise RuntimeError("{} is not an ArithUnaryFunction".format(g))
try:
h = make_Multiplies_complex_complex_double_double(c, d)
a = h.this
except:
print h, "is not an instance"
raise RuntimeError
raise RuntimeError("{} is not an instance".format(h))
s = "%s" % h
if str.find(s, "ArithUnaryFunction") == -1:
print h, "is not an ArithUnaryFunction"
raise RuntimeError
raise RuntimeError("{} is not an ArithUnaryFunction".format(h))

View File

@ -14,22 +14,19 @@ try:
e = make_Multiplies_float_float_float_float(d, d)
a = e.this
except:
print e, "is not an instance"
raise RuntimeError
raise RuntimeError("{} is not an instance".format(e))
try:
f = make_Multiplies_reald_reald_reald_reald(c, c)
a = f.this
except:
print f, "is not an instance"
raise RuntimeError
raise RuntimeError("{} is not an instance".format(f))
try:
g = make_Multiplies_float_float_reald_reald(d, c)
a = g.this
except:
print g, "is not an instance"
raise RuntimeError
raise RuntimeError("{} is not an instance".format(g))
# the old large format

View File

@ -13,7 +13,7 @@ m2 = MultimapAInt()
#dummy_pair = m2.make_dummy_pair()
#val = m2.typemap_test(dummy_pair)
# print val
# print("{}".format(val))
# if val != 4321:
# raise RuntimeError, "typemaps not working"

View File

@ -13,7 +13,7 @@ m2 = MultimapAInt()
#dummy_pair = m2.make_dummy_pair()
#val = m2.typemap_test(dummy_pair)
# print val
# print("{}".format(val))
# if val != 4321:
# raise RuntimeError, "typemaps not working"

View File

@ -5,19 +5,19 @@ b = typedef_inherit.Bar()
x = typedef_inherit.do_blah(a)
if x != "Foo::blah":
print "Whoa! Bad return", x
raise RuntimeError("Whoa! Bad return {}".format(x))
x = typedef_inherit.do_blah(b)
if x != "Bar::blah":
print "Whoa! Bad return", x
raise RuntimeError("Whoa! Bad return {}".format(x))
c = typedef_inherit.Spam()
d = typedef_inherit.Grok()
x = typedef_inherit.do_blah2(c)
if x != "Spam::blah":
print "Whoa! Bad return", x
raise RuntimeError("Whoa! Bad return {}".format(x))
x = typedef_inherit.do_blah2(d)
if x != "Grok::blah":
print "Whoa! Bad return", x
raise RuntimeError("Whoa! Bad return {}".format(x))

View File

@ -3,8 +3,8 @@ import typedef_scope
b = typedef_scope.Bar()
x = b.test1(42, "hello")
if x != 42:
print "Failed!!"
raise RuntimeError("Failed!!")
x = b.test2(42, "hello")
if x != "hello":
print "Failed!!"
raise RuntimeError("Failed!!")

View File

@ -3,7 +3,6 @@
# union embedded within a struct can be set and read correctly.
import unions
import sys
import string
# Create new instances of SmallStruct and BigStruct for later use
@ -23,28 +22,23 @@ eut.number = 1
eut.uni.small = small
Jill1 = eut.uni.small.jill
if (Jill1 != 200):
print "Runtime test1 failed. eut.uni.small.jill=", Jill1
sys.exit(1)
raise RuntimeError("Runtime test1 failed. eut.uni.small.jill={}".format(Jill1))
Num1 = eut.number
if (Num1 != 1):
print "Runtime test2 failed. eut.number=", Num1
sys.exit(1)
raise RuntimeError("Runtime test2 failed. eut.number=".format(Num1))
# Secondly check the BigStruct in EmbeddedUnionTest
eut.number = 2
eut.uni.big = big
Jack1 = eut.uni.big.jack
if (Jack1 != 300):
print "Runtime test3 failed. eut.uni.big.jack=", Jack1
sys.exit(1)
raise RuntimeError("Runtime test3 failed. eut.uni.big.jack={}".format(Jack1))
Jill2 = eut.uni.big.smallstruct.jill
if (Jill2 != 200):
print "Runtime test4 failed. eut.uni.big.smallstruct.jill=", Jill2
sys.exit(1)
raise RuntimeError("Runtime test4 failed. eut.uni.big.smallstruct.jill={}".format(Jill2))
Num2 = eut.number
if (Num2 != 2):
print "Runtime test5 failed. eut.number=", Num2
sys.exit(1)
raise RuntimeError("Runtime test5 failed. eut.number={}".format(Num2))