Convert python tests using 2to3
These tests were converted using 2to3 and should be valid using Python 2.7 and Python 3+.
This commit is contained in:
parent
66df0bd224
commit
d4ffa46f41
66 changed files with 551 additions and 551 deletions
|
|
@ -5,7 +5,7 @@ f.data = cvar.global_data
|
|||
|
||||
for i in range(0, 8):
|
||||
if get_value(f.data, i) != get_value(cvar.global_data, i):
|
||||
raise RuntimeError, "Bad array assignment"
|
||||
raise RuntimeError("Bad array assignment")
|
||||
|
||||
|
||||
for i in range(0, 8):
|
||||
|
|
@ -15,4 +15,4 @@ cvar.global_data = f.data
|
|||
|
||||
for i in range(0, 8):
|
||||
if get_value(f.data, i) != get_value(cvar.global_data, i):
|
||||
raise RuntimeError, "Bad array assignment"
|
||||
raise RuntimeError("Bad array assignment")
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ if t.ustrlen("hile") != 4:
|
|||
raise RuntimeError("bad multi-arg typemap {}".format(t.ustrlen("hile")))
|
||||
|
||||
if t.strlen("hil\0") != 4:
|
||||
raise RuntimeError, "bad multi-arg typemap"
|
||||
raise RuntimeError("bad multi-arg typemap")
|
||||
if t.ustrlen("hil\0") != 4:
|
||||
raise RuntimeError, "bad multi-arg typemap"
|
||||
raise RuntimeError("bad multi-arg typemap")
|
||||
|
||||
#
|
||||
# creating a raw char*
|
||||
|
|
@ -23,9 +23,9 @@ pchar_setitem(pc, 4, 0)
|
|||
|
||||
|
||||
if t.strlen(pc) != 4:
|
||||
raise RuntimeError, "bad multi-arg typemap"
|
||||
raise RuntimeError("bad multi-arg typemap")
|
||||
if t.ustrlen(pc) != 4:
|
||||
raise RuntimeError, "bad multi-arg typemap"
|
||||
raise RuntimeError("bad multi-arg typemap")
|
||||
|
||||
cvar.var_pchar = pc
|
||||
if cvar.var_pchar != "hola":
|
||||
|
|
@ -34,6 +34,6 @@ if cvar.var_pchar != "hola":
|
|||
cvar.var_namet = pc
|
||||
# if cvar.var_namet != "hola\0":
|
||||
if cvar.var_namet != "hola":
|
||||
raise RuntimeError, "bad pointer case"
|
||||
raise RuntimeError("bad pointer case")
|
||||
|
||||
delete_pchar(pc)
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@ import complextest
|
|||
a = complex(-1, 2)
|
||||
|
||||
if complextest.Conj(a) != a.conjugate():
|
||||
raise RuntimeError, "bad complex mapping"
|
||||
raise RuntimeError("bad complex mapping")
|
||||
|
||||
if complextest.Conjf(a) != a.conjugate():
|
||||
raise RuntimeError, "bad complex mapping"
|
||||
raise RuntimeError("bad complex mapping")
|
||||
|
||||
if complextest.Conj2(a) != a.conjugate():
|
||||
raise RuntimeError, "bad complex mapping"
|
||||
raise RuntimeError("bad complex mapping")
|
||||
|
||||
if complextest.Conjf2(a) != a.conjugate():
|
||||
raise RuntimeError, "bad complex mapping"
|
||||
raise RuntimeError("bad complex mapping")
|
||||
|
||||
|
||||
v = (complex(1, 2), complex(2, 3), complex(4, 3), 1)
|
||||
|
|
@ -27,4 +27,4 @@ p = complextest.ComplexPair()
|
|||
p.z1 = complex(0, 1)
|
||||
p.z2 = complex(0, -1)
|
||||
if complextest.Conj(p.z2) != p.z1:
|
||||
raise RuntimeError, "bad complex mapping"
|
||||
raise RuntimeError("bad complex mapping")
|
||||
|
|
|
|||
|
|
@ -4,20 +4,20 @@ a = cpp11_alternate_function_syntax.SomeStruct()
|
|||
|
||||
res = a.addNormal(4, 5)
|
||||
if res != 9:
|
||||
raise RuntimeError, ("SomeStruct::addNormal(4,5) returns ", res, " should be 9.")
|
||||
raise RuntimeError("SomeStruct::addNormal(4,5) returns ", res, " should be 9.")
|
||||
|
||||
res = a.addAlternate(4, 5)
|
||||
if res != 9:
|
||||
raise RuntimeError, ("SomeStruct::addAlternate(4,5) returns ", res, " should be 9.")
|
||||
raise RuntimeError("SomeStruct::addAlternate(4,5) returns ", res, " should be 9.")
|
||||
|
||||
res = a.addAlternateConst(4, 5)
|
||||
if res != 9:
|
||||
raise RuntimeError, ("SomeStruct::addAlternateConst(4,5) returns ", res, " should be 9.")
|
||||
raise RuntimeError("SomeStruct::addAlternateConst(4,5) returns ", res, " should be 9.")
|
||||
|
||||
res = a.addAlternateNoExcept(4, 5)
|
||||
if res != 9:
|
||||
raise RuntimeError, ("SomeStruct::addAlternateNoExcept(4,5) returns ", res, " should be 9.")
|
||||
raise RuntimeError("SomeStruct::addAlternateNoExcept(4,5) returns ", res, " should be 9.")
|
||||
|
||||
res = a.addAlternateConstNoExcept(4, 5)
|
||||
if res != 9:
|
||||
raise RuntimeError, ("SomeStruct::addAlternateConstNoExcept(4,5) returns ", res, " should be 9.")
|
||||
raise RuntimeError("SomeStruct::addAlternateConstNoExcept(4,5) returns ", res, " should be 9.")
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@ import cpp11_decltype
|
|||
a = cpp11_decltype.A()
|
||||
a.i = 5
|
||||
if a.i != 5:
|
||||
raise RuntimeError, "Assignment to a.i failed."
|
||||
raise RuntimeError("Assignment to a.i failed.")
|
||||
|
||||
a.j = 10
|
||||
if a.j != 10:
|
||||
raise RuntimeError, "Assignment to a.j failed."
|
||||
raise RuntimeError("Assignment to a.j failed.")
|
||||
|
||||
b = a.foo(5)
|
||||
if b != 10:
|
||||
raise RuntimeError, "foo(5) should return 10."
|
||||
raise RuntimeError("foo(5) should return 10.")
|
||||
|
||||
b = a.foo(6)
|
||||
if b != 0:
|
||||
raise RuntimeError, "foo(6) should return 0."
|
||||
raise RuntimeError("foo(6) should return 0.")
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ for x in [cpp11_hash_tables.MapIntInt({1:7}),
|
|||
cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})
|
||||
]:
|
||||
|
||||
swig_assert_equal([(k, v) for k, v in x.iteritems()], [(1, 7)])
|
||||
swig_assert_equal(x.keys(), [1])
|
||||
swig_assert_equal(x.values(), [7])
|
||||
swig_assert_equal(x.items(), [(1, 7)])
|
||||
swig_assert_equal([(k, v) for k, v in x.items()], [(1, 7)])
|
||||
swig_assert_equal(list(x.keys()), [1])
|
||||
swig_assert_equal(list(x.values()), [7])
|
||||
swig_assert_equal(list(x.items()), [(1, 7)])
|
||||
swig_assert_equal([k for k in x], [1])
|
||||
swig_assert_equal([i for i in x.iterkeys()], [1])
|
||||
swig_assert_equal([i for i in x.itervalues()], [7])
|
||||
swig_assert_equal([i for i in x.iteritems()], [(1, 7)])
|
||||
swig_assert_equal([i for i in x.keys()], [1])
|
||||
swig_assert_equal([i for i in x.values()], [7])
|
||||
swig_assert_equal([i for i in x.items()], [(1, 7)])
|
||||
|
||||
swig_assert_equal(x[1], 7)
|
||||
swig_assert_equal(2 in x, False)
|
||||
|
|
@ -33,7 +33,7 @@ for x in [cpp11_hash_tables.MapIntInt({1:7}),
|
|||
for x in [cpp11_hash_tables.MultiMapIntInt({1:7}),
|
||||
cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})]:
|
||||
x[1] = 9
|
||||
swig_assert_equal(sorted([v for k, v in x.iteritems()]), [7, 9])
|
||||
swig_assert_equal(sorted([v for k, v in x.items()]), [7, 9])
|
||||
swig_assert_equal(len(x), 2)
|
||||
|
||||
for x in [cpp11_hash_tables.SetInt([1]),
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@ import cpp11_null_pointer_constant
|
|||
a = cpp11_null_pointer_constant.A()
|
||||
|
||||
if a._myA != None:
|
||||
raise RuntimeError, (
|
||||
raise RuntimeError(
|
||||
"cpp11_null_pointer_constant: _myA should be None, but is ", a._myA)
|
||||
|
||||
b = cpp11_null_pointer_constant.A()
|
||||
if a._myA != b._myA:
|
||||
raise RuntimeError, (
|
||||
raise RuntimeError(
|
||||
"cpp11_null_pointer_constant: a._myA should be the same as b._myA, but ", a._myA, "!=", b._myA)
|
||||
|
||||
a._myA = cpp11_null_pointer_constant.A()
|
||||
if a._myA == None:
|
||||
raise RuntimeError, (
|
||||
"cpp11_null_pointer_constant: _myA should be object, but is None")
|
||||
raise RuntimeError((
|
||||
"cpp11_null_pointer_constant: _myA should be object, but is None"))
|
||||
|
|
|
|||
|
|
@ -34,19 +34,19 @@ if cvar.aa != "Wide string":
|
|||
raise RuntimeError
|
||||
|
||||
if cvar.bb != "UTF-8 string":
|
||||
raise RuntimeError, cvar.wide
|
||||
raise RuntimeError(cvar.wide)
|
||||
|
||||
if cvar.xx != ")I'm an \"ascii\" \\ string.":
|
||||
raise RuntimeError, cvar.xx
|
||||
raise RuntimeError(cvar.xx)
|
||||
|
||||
if cvar.ee != ")I'm an \"ascii\" \\ string.":
|
||||
raise RuntimeError, cvar.ee
|
||||
raise RuntimeError(cvar.ee)
|
||||
|
||||
if cvar.ff != "I'm a \"raw wide\" \\ string.":
|
||||
raise RuntimeError, cvar.ff
|
||||
raise RuntimeError(cvar.ff)
|
||||
|
||||
if cvar.gg != "I'm a \"raw UTF-8\" \\ string.":
|
||||
raise RuntimeError, cvar.gg
|
||||
raise RuntimeError(cvar.gg)
|
||||
|
||||
|
||||
def check(got, expected):
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ import cpp11_result_of
|
|||
|
||||
result = cpp11_result_of.test_result(cpp11_result_of.SQUARE, 3.0)
|
||||
if result != 9.0:
|
||||
raise RuntimeError, "test_result(square, 3.0) is not 9.0. Got: " + str(
|
||||
result)
|
||||
raise RuntimeError("test_result(square, 3.0) is not 9.0. Got: " + str(
|
||||
result))
|
||||
|
||||
result = cpp11_result_of.test_result_alternative1(cpp11_result_of.SQUARE, 3.0)
|
||||
if result != 9.0:
|
||||
raise RuntimeError, "test_result_alternative1(square, 3.0) is not 9.0. Got: " + str(
|
||||
result)
|
||||
raise RuntimeError("test_result_alternative1(square, 3.0) is not 9.0. Got: " + str(
|
||||
result))
|
||||
|
|
|
|||
|
|
@ -4,24 +4,24 @@ a = cpp11_rvalue_reference.A()
|
|||
|
||||
a.setAcopy(5)
|
||||
if a.getAcopy() != 5:
|
||||
raise RunTimeError, ("int A::getAcopy() value is ",
|
||||
raise RunTimeError("int A::getAcopy() value is ",
|
||||
a.getAcopy(), " should be 5")
|
||||
|
||||
ptr = a.getAptr()
|
||||
|
||||
a.setAptr(ptr)
|
||||
if a.getAcopy() != 5:
|
||||
raise RunTimeError, ("after A::setAptr(): int A::getAcopy() value is ", a.getAcopy(
|
||||
raise RunTimeError("after A::setAptr(): int A::getAcopy() value is ", a.getAcopy(
|
||||
), " should be 5")
|
||||
|
||||
a.setAref(ptr)
|
||||
if a.getAcopy() != 5:
|
||||
raise RunTimeError, ("after A::setAref(): int A::getAcopy() value is ", a.getAcopy(
|
||||
raise RunTimeError("after A::setAref(): int A::getAcopy() value is ", a.getAcopy(
|
||||
), " should be 5")
|
||||
|
||||
rvalueref = a.getAmove()
|
||||
|
||||
a.setAmove(rvalueref)
|
||||
if a.getAcopy() != 5:
|
||||
raise RunTimeError, ("after A::setAmove(): int A::getAcopy() value is ", a.getAcopy(
|
||||
raise RunTimeError("after A::setAmove(): int A::getAcopy() value is ", a.getAcopy(
|
||||
), " should be 5")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import sys
|
|||
|
||||
|
||||
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):
|
||||
|
|
@ -26,8 +26,8 @@ def steps_exception(swigarray, i, j, step):
|
|||
a = swigarray[i::step]
|
||||
else:
|
||||
a = swigarray[i:j:step]
|
||||
raise RuntimeError, "swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed steps exception for " + str(list(swigarray))
|
||||
except ValueError, e:
|
||||
raise RuntimeError("swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed steps exception for " + str(list(swigarray)))
|
||||
except ValueError as e:
|
||||
# print("exception: {}".format(e))
|
||||
pass
|
||||
|
||||
|
|
@ -43,16 +43,16 @@ def del_exception(swigarray, i, j, step):
|
|||
del swigarray[i::step]
|
||||
else:
|
||||
del swigarray[i:j:step]
|
||||
raise RuntimeError, "swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed del exception for " + str(list(swigarray))
|
||||
except ValueError, e:
|
||||
raise RuntimeError("swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed del exception for " + str(list(swigarray)))
|
||||
except ValueError as e:
|
||||
# print("exception: {}".format(e))
|
||||
pass
|
||||
|
||||
def setslice_exception(swigarray, newval):
|
||||
try:
|
||||
swigarray[::] = newval
|
||||
raise RuntimeError, "swigarray[::] = " + str(newval) + " missed set exception for swigarray:" + str(list(swigarray))
|
||||
except TypeError, e:
|
||||
raise RuntimeError("swigarray[::] = " + str(newval) + " missed set exception for swigarray:" + str(list(swigarray)))
|
||||
except TypeError as e:
|
||||
# print("exception: {}".format(e))
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ if var2.getX() != 2:
|
|||
|
||||
m = cpp11_uniform_initialization.MoreInit()
|
||||
if m.charptr != None:
|
||||
raise RuntimeError, m.charptr
|
||||
raise RuntimeError(m.charptr)
|
||||
m.charptr = "hello sir"
|
||||
if m.charptr != "hello sir":
|
||||
raise RuntimeError, m.charptr
|
||||
raise RuntimeError(m.charptr)
|
||||
if m.more1(m.vi) != 15:
|
||||
raise RuntimeError, m.vi
|
||||
raise RuntimeError(m.vi)
|
||||
if m.more1([-1, 1, 2]) != 2:
|
||||
raise RuntimeError, m.vi
|
||||
raise RuntimeError(m.vi)
|
||||
if m.more1() != 10:
|
||||
raise RuntimeError
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ class MyFoo(director_abstract.Foo):
|
|||
a = MyFoo()
|
||||
|
||||
if a.ping() != "MyFoo::ping()":
|
||||
raise RuntimeError, a.ping()
|
||||
raise RuntimeError(a.ping())
|
||||
|
||||
if a.pong() != "Foo::pong();MyFoo::ping()":
|
||||
raise RuntimeError, a.pong()
|
||||
raise RuntimeError(a.pong())
|
||||
|
||||
|
||||
class MyExample1(director_abstract.Example1):
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@ from director_alternating import *
|
|||
|
||||
id = getBar().id()
|
||||
if id != idFromGetBar():
|
||||
raise RuntimeError, "Got wrong id: " + str(id)
|
||||
raise RuntimeError("Got wrong id: " + str(id))
|
||||
|
|
|
|||
|
|
@ -10,18 +10,18 @@ class PyFoo(director_basic.Foo):
|
|||
a = PyFoo()
|
||||
|
||||
if a.ping() != "PyFoo::ping()":
|
||||
raise RuntimeError, a.ping()
|
||||
raise RuntimeError(a.ping())
|
||||
|
||||
if a.pong() != "Foo::pong();PyFoo::ping()":
|
||||
raise RuntimeError, a.pong()
|
||||
raise RuntimeError(a.pong())
|
||||
|
||||
b = director_basic.Foo()
|
||||
|
||||
if b.ping() != "Foo::ping()":
|
||||
raise RuntimeError, b.ping()
|
||||
raise RuntimeError(b.ping())
|
||||
|
||||
if b.pong() != "Foo::pong();Foo::ping()":
|
||||
raise RuntimeError, b.pong()
|
||||
raise RuntimeError(b.pong())
|
||||
|
||||
a = director_basic.A1(1)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ class PyFoo(director_comparison_operators.Foo):
|
|||
a = PyFoo()
|
||||
|
||||
if a.test() != "a=1,b=2":
|
||||
raise RuntimeError, a.test()
|
||||
raise RuntimeError(a.test())
|
||||
|
|
|
|||
|
|
@ -35,4 +35,4 @@ c = b.clone()
|
|||
vc = c.get_value()
|
||||
|
||||
if (v != 3) or (b.val != 5) or (vc != 6):
|
||||
raise RuntimeError, "Bad virtual detection"
|
||||
raise RuntimeError("Bad virtual detection")
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class MyException(Exception):
|
|||
class MyFoo(Foo):
|
||||
|
||||
def ping(self):
|
||||
raise NotImplementedError, "MyFoo::ping() EXCEPTION"
|
||||
raise NotImplementedError("MyFoo::ping() EXCEPTION")
|
||||
|
||||
|
||||
class MyFoo2(Foo):
|
||||
|
|
@ -39,7 +39,7 @@ b = launder(a)
|
|||
try:
|
||||
b.pong()
|
||||
raise RuntimeError("Exception was not thrown")
|
||||
except NotImplementedError, e:
|
||||
except NotImplementedError as e:
|
||||
if not str(e) == "MyFoo::ping() EXCEPTION":
|
||||
raise RuntimeError("Unexpected error message: %s" % str(e))
|
||||
except TypeError:
|
||||
|
|
@ -53,7 +53,7 @@ b = launder(a)
|
|||
try:
|
||||
b.pong()
|
||||
raise RuntimeError("Exception was not thrown")
|
||||
except TypeError, e:
|
||||
except TypeError as e:
|
||||
# fastdispatch mode adds on Additional Information to the exception message - just check the main exception message exists
|
||||
if not str(e).startswith("SWIG director type mismatch in output value of type 'std::string'"):
|
||||
raise RuntimeError("Unexpected error message: %s" % str(e))
|
||||
|
|
@ -66,7 +66,7 @@ b = launder(a)
|
|||
try:
|
||||
b.pong()
|
||||
raise RuntimeError("Exception was not thrown")
|
||||
except MyException, e:
|
||||
except MyException as e:
|
||||
if e.msg != "foobar":
|
||||
raise RuntimeError("Unexpected error message: %s" % str(e))
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,6 @@ class MyObject(SpObject):
|
|||
|
||||
m = MyObject()
|
||||
if m.dummy() != 666:
|
||||
raise RuntimeError, "1st call"
|
||||
raise RuntimeError("1st call")
|
||||
if m.dummy() != 666: # Locked system
|
||||
raise RuntimeError, "2nd call"
|
||||
raise RuntimeError("2nd call")
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@ foo = Bravo()
|
|||
s = foo.abs_method()
|
||||
|
||||
if s != "Bravo::abs_method()":
|
||||
raise RuntimeError, s
|
||||
raise RuntimeError(s)
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue