summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2020-08-13 21:22:47 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2020-08-13 21:22:47 +0100
commit365d4961d485df0fde081e6f05e75ab23b124ea9 (patch)
tree307eedcc52ad3d06ce3267e07eaca474fc6248a4
parente535190c34636113de375fcaf7b897ec1738c00f (diff)
downloadswig-365d4961d485df0fde081e6f05e75ab23b124ea9.tar.gz
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.
-rw-r--r--Examples/test-suite/python/argcargvtest_runme.py1
-rw-r--r--Examples/test-suite/python/char_binary_runme.py9
-rw-r--r--Examples/test-suite/python/constover_runme.py19
-rw-r--r--Examples/test-suite/python/cpp_enum_runme.py12
-rw-r--r--Examples/test-suite/python/default_args_runme.py34
-rw-r--r--Examples/test-suite/python/director_exception_runme.py38
-rw-r--r--Examples/test-suite/python/director_profile_runme.py2
-rw-r--r--Examples/test-suite/python/director_string_runme.py6
-rw-r--r--Examples/test-suite/python/director_thread_runme.py3
-rw-r--r--Examples/test-suite/python/director_unroll_runme.py3
-rw-r--r--Examples/test-suite/python/director_wstring_runme.py6
-rw-r--r--Examples/test-suite/python/dynamic_cast_runme.py2
-rw-r--r--Examples/test-suite/python/exception_order_runme.py3
-rw-r--r--Examples/test-suite/python/inctest_runme.py18
-rw-r--r--Examples/test-suite/python/inherit_missing_runme.py6
-rw-r--r--Examples/test-suite/python/inplaceadd_runme.py3
-rw-r--r--Examples/test-suite/python/li_attribute_runme.py6
-rw-r--r--Examples/test-suite/python/li_attribute_template_runme.py3
-rw-r--r--Examples/test-suite/python/li_cstring_runme.py6
-rw-r--r--Examples/test-suite/python/li_std_map_runme.py3
-rw-r--r--Examples/test-suite/python/li_std_stream_runme.py3
-rw-r--r--Examples/test-suite/python/li_std_string_extra_runme.py9
-rw-r--r--Examples/test-suite/python/li_std_wstream_runme.py3
-rw-r--r--Examples/test-suite/python/li_std_wstring_inherit_runme.py3
-rw-r--r--Examples/test-suite/python/primitive_types_runme.py24
-rw-r--r--Examples/test-suite/python/python_nondynamic_runme.py8
-rw-r--r--Examples/test-suite/python/python_pickle_runme.py8
-rw-r--r--Examples/test-suite/python/python_pybuffer_runme.py4
-rw-r--r--Examples/test-suite/python/return_const_value_runme.py6
-rw-r--r--Examples/test-suite/python/smart_pointer_member_runme.py4
-rw-r--r--Examples/test-suite/python/std_containers_runme.py3
-rw-r--r--Examples/test-suite/python/swigobject_runme.py3
-rw-r--r--Examples/test-suite/python/template_typedef_cplx2_runme.py39
-rw-r--r--Examples/test-suite/python/template_typedef_cplx_runme.py36
-rw-r--r--Examples/test-suite/python/template_typedef_runme.py9
-rw-r--r--Examples/test-suite/python/template_typemaps_typedef2_runme.py2
-rw-r--r--Examples/test-suite/python/template_typemaps_typedef_runme.py2
-rw-r--r--Examples/test-suite/python/typedef_inherit_runme.py8
-rw-r--r--Examples/test-suite/python/typedef_scope_runme.py4
-rw-r--r--Examples/test-suite/python/unions_runme.py16
40 files changed, 123 insertions, 254 deletions
diff --git a/Examples/test-suite/python/argcargvtest_runme.py b/Examples/test-suite/python/argcargvtest_runme.py
index b0345746f..eb57f79ea 100644
--- a/Examples/test-suite/python/argcargvtest_runme.py
+++ b/Examples/test-suite/python/argcargvtest_runme.py
@@ -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")
diff --git a/Examples/test-suite/python/char_binary_runme.py b/Examples/test-suite/python/char_binary_runme.py
index 0425fe1c9..83ae9f0ec 100644
--- a/Examples/test-suite/python/char_binary_runme.py
+++ b/Examples/test-suite/python/char_binary_runme.py
@@ -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":
diff --git a/Examples/test-suite/python/constover_runme.py b/Examples/test-suite/python/constover_runme.py
index 2d28a55cc..0c03967f6 100644
--- a/Examples/test-suite/python/constover_runme.py
+++ b/Examples/test-suite/python/constover_runme.py
@@ -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)
diff --git a/Examples/test-suite/python/cpp_enum_runme.py b/Examples/test-suite/python/cpp_enum_runme.py
index 5f1e91c97..910d378e4 100644
--- a/Examples/test-suite/python/cpp_enum_runme.py
+++ b/Examples/test-suite/python/cpp_enum_runme.py
@@ -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))
diff --git a/Examples/test-suite/python/default_args_runme.py b/Examples/test-suite/python/default_args_runme.py
index 14ef8c594..0ce47ab79 100644
--- a/Examples/test-suite/python/default_args_runme.py
+++ b/Examples/test-suite/python/default_args_runme.py
@@ -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)
diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py
index 06856f30a..5b715bae6 100644
--- a/Examples/test-suite/python/director_exception_runme.py
+++ b/Examples/test-suite/python/director_exception_runme.py
@@ -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
diff --git a/Examples/test-suite/python/director_profile_runme.py b/Examples/test-suite/python/director_profile_runme.py
index 035007c61..7c269c3f7 100644
--- a/Examples/test-suite/python/director_profile_runme.py
+++ b/Examples/test-suite/python/director_profile_runme.py
@@ -38,4 +38,4 @@ while i:
a = fi(a) # 20
i -= 1
-print a
+print("a: {}".format(a))
diff --git a/Examples/test-suite/python/director_string_runme.py b/Examples/test-suite/python/director_string_runme.py
index dcd47d647..c6d4c8121 100644
--- a/Examples/test-suite/python/director_string_runme.py
+++ b/Examples/test-suite/python/director_string_runme.py
@@ -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))
diff --git a/Examples/test-suite/python/director_thread_runme.py b/Examples/test-suite/python/director_thread_runme.py
index 4fcf3bfd1..21a8ce1b0 100644
--- a/Examples/test-suite/python/director_thread_runme.py
+++ b/Examples/test-suite/python/director_thread_runme.py
@@ -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()
diff --git a/Examples/test-suite/python/director_unroll_runme.py b/Examples/test-suite/python/director_unroll_runme.py
index 60bc05585..ea602d8e2 100644
--- a/Examples/test-suite/python/director_unroll_runme.py
+++ b/Examples/test-suite/python/director_unroll_runme.py
@@ -16,5 +16,4 @@ c = b.get()
if not (a.this == c.this):
- print a, c
- raise RuntimeError
+ raise RuntimeError("{} {}".format(a, c))
diff --git a/Examples/test-suite/python/director_wstring_runme.py b/Examples/test-suite/python/director_wstring_runme.py
index b7929c0d2..b6e25f4d5 100644
--- a/Examples/test-suite/python/director_wstring_runme.py
+++ b/Examples/test-suite/python/director_wstring_runme.py
@@ -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))
diff --git a/Examples/test-suite/python/dynamic_cast_runme.py b/Examples/test-suite/python/dynamic_cast_runme.py
index 59e86d34c..ae080833b 100644
--- a/Examples/test-suite/python/dynamic_cast_runme.py
+++ b/Examples/test-suite/python/dynamic_cast_runme.py
@@ -8,4 +8,4 @@ y = b.blah()
a = dynamic_cast.do_test(y)
if a != "Bar::test":
- print "Failed!!"
+ raise RuntimeError("Failed!!")
diff --git a/Examples/test-suite/python/exception_order_runme.py b/Examples/test-suite/python/exception_order_runme.py
index c53521e3e..aa97e26e6 100644
--- a/Examples/test-suite/python/exception_order_runme.py
+++ b/Examples/test-suite/python/exception_order_runme.py
@@ -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:
diff --git a/Examples/test-suite/python/inctest_runme.py b/Examples/test-suite/python/inctest_runme.py
index fa3492932..c2746560d 100644
--- a/Examples/test-suite/python/inctest_runme.py
+++ b/Examples/test-suite/python/inctest_runme.py
@@ -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")
diff --git a/Examples/test-suite/python/inherit_missing_runme.py b/Examples/test-suite/python/inherit_missing_runme.py
index 044c166fb..57a245e44 100644
--- a/Examples/test-suite/python/inherit_missing_runme.py
+++ b/Examples/test-suite/python/inherit_missing_runme.py
@@ -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)
diff --git a/Examples/test-suite/python/inplaceadd_runme.py b/Examples/test-suite/python/inplaceadd_runme.py
index 7f292cbb5..3d5a1fd40 100644
--- a/Examples/test-suite/python/inplaceadd_runme.py
+++ b/Examples/test-suite/python/inplaceadd_runme.py
@@ -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:
diff --git a/Examples/test-suite/python/li_attribute_runme.py b/Examples/test-suite/python/li_attribute_runme.py
index 80e793618..764bcdb55 100644
--- a/Examples/test-suite/python/li_attribute_runme.py
+++ b/Examples/test-suite/python/li_attribute_runme.py
@@ -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
diff --git a/Examples/test-suite/python/li_attribute_template_runme.py b/Examples/test-suite/python/li_attribute_template_runme.py
index d33b12309..f0a774995 100644
--- a/Examples/test-suite/python/li_attribute_template_runme.py
+++ b/Examples/test-suite/python/li_attribute_template_runme.py
@@ -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)
diff --git a/Examples/test-suite/python/li_cstring_runme.py b/Examples/test-suite/python/li_cstring_runme.py
index b718f1352..d22fc261b 100644
--- a/Examples/test-suite/python/li_cstring_runme.py
+++ b/Examples/test-suite/python/li_cstring_runme.py
@@ -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
diff --git a/Examples/test-suite/python/li_std_map_runme.py b/Examples/test-suite/python/li_std_map_runme.py
index ac214dd45..f53d3f56b 100644
--- a/Examples/test-suite/python/li_std_map_runme.py
+++ b/Examples/test-suite/python/li_std_map_runme.py
@@ -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 = {}
diff --git a/Examples/test-suite/python/li_std_stream_runme.py b/Examples/test-suite/python/li_std_stream_runme.py
index 08c308856..a4526f07b 100644
--- a/Examples/test-suite/python/li_std_stream_runme.py
+++ b/Examples/test-suite/python/li_std_stream_runme.py
@@ -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()))
diff --git a/Examples/test-suite/python/li_std_string_extra_runme.py b/Examples/test-suite/python/li_std_string_extra_runme.py
index 087d92b19..9d3bad03a 100644
--- a/Examples/test-suite/python/li_std_string_extra_runme.py
+++ b/Examples/test-suite/python/li_std_string_extra_runme.py
@@ -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"
diff --git a/Examples/test-suite/python/li_std_wstream_runme.py b/Examples/test-suite/python/li_std_wstream_runme.py
index 045645b61..a83561a84 100644
--- a/Examples/test-suite/python/li_std_wstream_runme.py
+++ b/Examples/test-suite/python/li_std_wstream_runme.py
@@ -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()))
diff --git a/Examples/test-suite/python/li_std_wstring_inherit_runme.py b/Examples/test-suite/python/li_std_wstring_inherit_runme.py
index 558914e7e..5a8569a6f 100644
--- a/Examples/test-suite/python/li_std_wstring_inherit_runme.py
+++ b/Examples/test-suite/python/li_std_wstring_inherit_runme.py
@@ -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")
diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py
index 04588ddf2..729b450a6 100644
--- a/Examples/test-suite/python/primitive_types_runme.py
+++ b/Examples/test-suite/python/primitive_types_runme.py
@@ -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":
diff --git a/Examples/test-suite/python/python_nondynamic_runme.py b/Examples/test-suite/python/python_nondynamic_runme.py
index fbb60ad36..524f4d1c4 100644
--- a/Examples/test-suite/python/python_nondynamic_runme.py
+++ b/Examples/test-suite/python/python_nondynamic_runme.py
@@ -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
diff --git a/Examples/test-suite/python/python_pickle_runme.py b/Examples/test-suite/python/python_pickle_runme.py
index 27c67ae10..cbe425fa2 100644
--- a/Examples/test-suite/python/python_pickle_runme.py
+++ b/Examples/test-suite/python/python_pickle_runme.py
@@ -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))
diff --git a/Examples/test-suite/python/python_pybuffer_runme.py b/Examples/test-suite/python/python_pybuffer_runme.py
index 8ecdb523b..86f43b608 100644
--- a/Examples/test-suite/python/python_pybuffer_runme.py
+++ b/Examples/test-suite/python/python_pybuffer_runme.py
@@ -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)
diff --git a/Examples/test-suite/python/return_const_value_runme.py b/Examples/test-suite/python/return_const_value_runme.py
index ff3bd5f02..809eed97a 100644
--- a/Examples/test-suite/python/return_const_value_runme.py
+++ b/Examples/test-suite/python/return_const_value_runme.py
@@ -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()))
diff --git a/Examples/test-suite/python/smart_pointer_member_runme.py b/Examples/test-suite/python/smart_pointer_member_runme.py
index d2ed87e79..9758b0ba4 100644
--- a/Examples/test-suite/python/smart_pointer_member_runme.py
+++ b/Examples/test-suite/python/smart_pointer_member_runme.py
@@ -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
diff --git a/Examples/test-suite/python/std_containers_runme.py b/Examples/test-suite/python/std_containers_runme.py
index 7404cd5f4..51bd2a7b8 100644
--- a/Examples/test-suite/python/std_containers_runme.py
+++ b/Examples/test-suite/python/std_containers_runme.py
@@ -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))
diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py
index de232f580..3b18a6b74 100644
--- a/Examples/test-suite/python/swigobject_runme.py
+++ b/Examples/test-suite/python/swigobject_runme.py
@@ -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)
diff --git a/Examples/test-suite/python/template_typedef_cplx2_runme.py b/Examples/test-suite/python/template_typedef_cplx2_runme.py
index 161bd51fc..23f19efb9 100644
--- a/Examples/test-suite/python/template_typedef_cplx2_runme.py
+++ b/Examples/test-suite/python/template_typedef_cplx2_runme.py
@@ -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))
diff --git a/Examples/test-suite/python/template_typedef_cplx_runme.py b/Examples/test-suite/python/template_typedef_cplx_runme.py
index 1846739eb..69d5642d6 100644
--- a/Examples/test-suite/python/template_typedef_cplx_runme.py
+++ b/Examples/test-suite/python/template_typedef_cplx_runme.py
@@ -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))
diff --git a/Examples/test-suite/python/template_typedef_runme.py b/Examples/test-suite/python/template_typedef_runme.py
index 16695bada..5723e4f59 100644
--- a/Examples/test-suite/python/template_typedef_runme.py
+++ b/Examples/test-suite/python/template_typedef_runme.py
@@ -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
diff --git a/Examples/test-suite/python/template_typemaps_typedef2_runme.py b/Examples/test-suite/python/template_typemaps_typedef2_runme.py
index 258f44366..2b8bd5631 100644
--- a/Examples/test-suite/python/template_typemaps_typedef2_runme.py
+++ b/Examples/test-suite/python/template_typemaps_typedef2_runme.py
@@ -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"
diff --git a/Examples/test-suite/python/template_typemaps_typedef_runme.py b/Examples/test-suite/python/template_typemaps_typedef_runme.py
index 1ca3f835c..d84be64ff 100644
--- a/Examples/test-suite/python/template_typemaps_typedef_runme.py
+++ b/Examples/test-suite/python/template_typemaps_typedef_runme.py
@@ -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"
diff --git a/Examples/test-suite/python/typedef_inherit_runme.py b/Examples/test-suite/python/typedef_inherit_runme.py
index 6b7f2d872..3c552ec65 100644
--- a/Examples/test-suite/python/typedef_inherit_runme.py
+++ b/Examples/test-suite/python/typedef_inherit_runme.py
@@ -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))
diff --git a/Examples/test-suite/python/typedef_scope_runme.py b/Examples/test-suite/python/typedef_scope_runme.py
index edd3e9f3a..0294c4a07 100644
--- a/Examples/test-suite/python/typedef_scope_runme.py
+++ b/Examples/test-suite/python/typedef_scope_runme.py
@@ -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!!")
diff --git a/Examples/test-suite/python/unions_runme.py b/Examples/test-suite/python/unions_runme.py
index 387a048c8..5a3ee3b5c 100644
--- a/Examples/test-suite/python/unions_runme.py
+++ b/Examples/test-suite/python/unions_runme.py
@@ -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))