Merge branch 'remove-dependency-on-2to3'
* remove-dependency-on-2to3: Remove need for Python 2to3 Modify examples to be both Python 2 and 3 compatible Remove python3 specific runme3.py test files Convert python tests using 2to3 Convert python test scripts to be Python 2 and 3 compatible Convert swigobject python test to be python 2 and 3 compatible Convert two tests to work with both Python 2 and 3 Improve director_exception Python test Remove further print statements from Python tests Improve Python testing catching exceptions Improve contract Python testcase testing Remove print statements from Python tests
This commit is contained in:
commit
baec830f75
106 changed files with 1193 additions and 1427 deletions
|
|
@ -10,20 +10,10 @@ endif
|
|||
|
||||
LANGUAGE = python
|
||||
PYTHON = $(PYBIN)
|
||||
SCRIPTSUFFIX = _runme.py
|
||||
PYCODESTYLE = @PYCODESTYLE@
|
||||
PYCODESTYLE_FLAGS = --ignore=E252,E30,E402,E501,E731,E741,W291,W391
|
||||
|
||||
#*_runme.py for Python 2.x, *_runme3.py for Python 3.x
|
||||
PY2SCRIPTSUFFIX = _runme.py
|
||||
PY3SCRIPTSUFFIX = _runme3.py
|
||||
PY2TO3 = @PY2TO3@ -x import
|
||||
|
||||
ifeq (,$(PY3))
|
||||
SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX)
|
||||
else
|
||||
SCRIPTSUFFIX = $(PY3SCRIPTSUFFIX)
|
||||
endif
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
|
@ -108,7 +98,6 @@ C_TEST_CASES += \
|
|||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
SCRIPTDIR = .
|
||||
LIBS = -L.
|
||||
VALGRIND_OPT += --suppressions=pythonswig.supp
|
||||
|
||||
|
|
@ -117,35 +106,25 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
|
|||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
+$(convert_testcase)
|
||||
$(setup)
|
||||
+$(swig_and_compile_cpp)
|
||||
$(check_pep8)
|
||||
$(run_testcase)
|
||||
|
||||
%.ctest:
|
||||
+$(convert_testcase)
|
||||
$(setup)
|
||||
+$(swig_and_compile_c)
|
||||
$(check_pep8)
|
||||
$(run_testcase)
|
||||
|
||||
%.multicpptest:
|
||||
+$(convert_testcase)
|
||||
$(setup)
|
||||
+$(swig_and_compile_multi_cpp)
|
||||
$(check_pep8_multi_cpp)
|
||||
$(run_testcase)
|
||||
|
||||
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name.
|
||||
|
||||
py_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
|
||||
py2_runme = $(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
|
||||
py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
|
||||
|
||||
# Python code style checking
|
||||
ifneq (,$(PYCODESTYLE))
|
||||
check_pep8 = $(COMPILETOOL) $(PYCODESTYLE) $(PYCODESTYLE_FLAGS) $(SCRIPTPREFIX)$*.py
|
||||
|
||||
|
|
@ -155,70 +134,16 @@ check_pep8_multi_cpp = \
|
|||
done
|
||||
endif
|
||||
|
||||
run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(py_runme)
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.py appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(SCRIPTDIR)/$(py_runme) ]; then \
|
||||
$(run_python);\
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Grab runme file ready for running: copied for out of source tree builds, and/or run 2to3
|
||||
# Note terminal (double colon) rules creating runme files to fix possible infinite recursion,
|
||||
# see https://github.com/swig/swig/pull/688
|
||||
ifeq ($(SCRIPTDIR),$(srcdir))
|
||||
# in source tree build
|
||||
ifeq (,$(PY3))
|
||||
convert_testcase =
|
||||
else
|
||||
convert_testcase = \
|
||||
if [ -f $(srcdir)/$(py2_runme) ]; then \
|
||||
$(MAKE) $(SCRIPTDIR)/$(py_runme); \
|
||||
fi
|
||||
|
||||
# For converting python 2 tests into Python 3 tests
|
||||
$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX)
|
||||
cp $< $@
|
||||
$(PY2TO3) -w $@ >/dev/null 2>&1
|
||||
|
||||
endif
|
||||
else
|
||||
# out of source tree build
|
||||
ifeq (,$(PY3))
|
||||
convert_testcase = \
|
||||
if [ -f $(srcdir)/$(py2_runme) ]; then \
|
||||
$(MAKE) $(SCRIPTDIR)/$(py_runme); \
|
||||
fi
|
||||
|
||||
$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX)
|
||||
cp $< $@
|
||||
|
||||
else
|
||||
convert_testcase = \
|
||||
if [ -f $(srcdir)/$(py2_runme) ]; then \
|
||||
$(MAKE) $(SCRIPTDIR)/$(py_runme); \
|
||||
elif [ -f $(srcdir)/$(py3_runme) ]; then \
|
||||
$(MAKE) $(SCRIPTDIR)/$(py3_runme); \
|
||||
fi
|
||||
|
||||
# For when there is a _runme3.py instead of a _runme.py, ie a Python 3 only run test
|
||||
$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY3SCRIPTSUFFIX)
|
||||
cp $< $@
|
||||
|
||||
# For converting python 2 tests into Python 3 tests
|
||||
$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX)
|
||||
cp $< $@
|
||||
$(PY2TO3) -w $@ >/dev/null 2>&1
|
||||
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
# Clean: remove the generated .py file
|
||||
# We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
|
||||
%.clean:
|
||||
@rm -f $*.py
|
||||
@if test -f $(srcdir)/$(py2_runme); then rm -f $(SCRIPTDIR)/$(py3_runme) $(SCRIPTDIR)/$(py3_runme).bak; fi
|
||||
@if test "x$(SCRIPTDIR)" != "x$(srcdir)"; then rm -f $(SCRIPTDIR)/$(py_runme); fi
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' python_clean
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -2,16 +2,14 @@ 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"
|
||||
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*
|
||||
|
|
@ -25,18 +23,17 @@ 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":
|
||||
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":
|
||||
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,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)
|
||||
|
|
|
|||
|
|
@ -2,141 +2,141 @@ import contract
|
|||
|
||||
contract.test_preassert(1, 2)
|
||||
try:
|
||||
contract.test_preassert(-1)
|
||||
print "Failed! Preassertions are broken"
|
||||
except:
|
||||
contract.test_preassert(-1, 3)
|
||||
raise Exception("Failed! Preassertions are broken")
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
contract.test_postassert(3)
|
||||
try:
|
||||
contract.test_postassert(-3)
|
||||
print "Failed! Postassertions are broken"
|
||||
except:
|
||||
raise Exception("Failed! Postassertions are broken")
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
contract.test_prepost(2, 3)
|
||||
contract.test_prepost(5, -4)
|
||||
try:
|
||||
contract.test_prepost(-3, 4)
|
||||
print "Failed! Preassertions are broken"
|
||||
except:
|
||||
raise Exception("Failed! Preassertions are broken")
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
try:
|
||||
contract.test_prepost(4, -10)
|
||||
print "Failed! Postassertions are broken"
|
||||
raise Exception("Failed! Postassertions are broken")
|
||||
|
||||
except:
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
f = contract.Foo()
|
||||
f.test_preassert(4, 5)
|
||||
try:
|
||||
f.test_preassert(-2, 3)
|
||||
print "Failed! Method preassertion."
|
||||
except:
|
||||
raise Exception("Failed! Method preassertion.")
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
f.test_postassert(4)
|
||||
try:
|
||||
f.test_postassert(-4)
|
||||
print "Failed! Method postassertion"
|
||||
except:
|
||||
raise Exception("Failed! Method postassertion")
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
f.test_prepost(3, 4)
|
||||
f.test_prepost(4, -3)
|
||||
try:
|
||||
f.test_prepost(-4, 2)
|
||||
print "Failed! Method preassertion."
|
||||
except:
|
||||
raise Exception("Failed! Method preassertion.")
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
try:
|
||||
f.test_prepost(4, -10)
|
||||
print "Failed! Method postassertion."
|
||||
except:
|
||||
raise Exception("Failed! Method postassertion.")
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
contract.Foo_stest_prepost(4, 0)
|
||||
try:
|
||||
contract.Foo_stest_prepost(-4, 2)
|
||||
print "Failed! Static method preassertion"
|
||||
except:
|
||||
raise Exception("Failed! Static method preassertion")
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
try:
|
||||
contract.Foo_stest_prepost(4, -10)
|
||||
print "Failed! Static method posteassertion"
|
||||
except:
|
||||
raise Exception("Failed! Static method posteassertion")
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
b = contract.Bar()
|
||||
try:
|
||||
b.test_prepost(2, -4)
|
||||
print "Failed! Inherited preassertion."
|
||||
except:
|
||||
raise Exception("Failed! Inherited preassertion.")
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
|
||||
d = contract.D()
|
||||
try:
|
||||
d.foo(-1, 1, 1, 1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
raise Exception("Failed! Inherited preassertion (D).")
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.foo(1, -1, 1, 1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
raise Exception("Failed! Inherited preassertion (D).")
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.foo(1, 1, -1, 1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
raise Exception("Failed! Inherited preassertion (D).")
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.foo(1, 1, 1, -1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
raise Exception("Failed! Inherited preassertion (D).")
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.foo(1, 1, 1, 1, -1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
raise Exception("Failed! Inherited preassertion (D).")
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
d.bar(-1, 1, 1, 1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
raise Exception("Failed! Inherited preassertion (D).")
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.bar(1, -1, 1, 1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
raise Exception("Failed! Inherited preassertion (D).")
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.bar(1, 1, -1, 1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
raise Exception("Failed! Inherited preassertion (D).")
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.bar(1, 1, 1, -1, 1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
raise Exception("Failed! Inherited preassertion (D).")
|
||||
except RuntimeError:
|
||||
pass
|
||||
try:
|
||||
d.bar(1, 1, 1, 1, -1)
|
||||
print "Failed! Inherited preassertion (D)."
|
||||
except:
|
||||
raise Exception("Failed! Inherited preassertion (D).")
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
# Namespace
|
||||
my = contract.myClass(1)
|
||||
try:
|
||||
my = contract.myClass(0)
|
||||
print "Failed! constructor preassertion"
|
||||
except:
|
||||
raise Exception("Failed! constructor preassertion")
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,24 +16,24 @@ dc.delete_AA(aa)
|
|||
|
||||
try:
|
||||
b = dc.new_B()
|
||||
print "Whoa. new_BB created."
|
||||
except:
|
||||
raise RuntimeError("Whoa. new_BB created.")
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
del_b = dc.delete_B
|
||||
|
||||
try:
|
||||
bb = dc.new_BB()
|
||||
print "Whoa. new_BB created."
|
||||
except:
|
||||
raise RuntimeError("Whoa. new_BB created.")
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
del_bb = dc.delete_BB
|
||||
|
||||
try:
|
||||
c = dc.new_C()
|
||||
print "Whoa. new_C created."
|
||||
except:
|
||||
raise RuntimeError("Whoa. new_C created.")
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
del_c = dc.delete_C
|
||||
|
|
@ -43,24 +43,24 @@ dc.delete_CC(cc)
|
|||
|
||||
try:
|
||||
d = dc.new_D()
|
||||
print "Whoa. new_D created"
|
||||
except:
|
||||
raise RuntimeError("Whoa. new_D created")
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
del_d = dc.delete_D
|
||||
|
||||
try:
|
||||
dd = dc.new_DD()
|
||||
print "Whoa. new_DD created"
|
||||
except:
|
||||
raise RuntimeError("Whoa. new_DD created")
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
dd = dc.delete_DD
|
||||
|
||||
try:
|
||||
ad = dc.new_AD()
|
||||
print "Whoa. new_AD created"
|
||||
except:
|
||||
raise RuntimeError("Whoa. new_AD created")
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
del_ad = dc.delete_AD
|
||||
|
|
@ -73,8 +73,8 @@ dc.delete_EE(ee)
|
|||
|
||||
try:
|
||||
eb = dc.new_EB()
|
||||
print "Whoa. new_EB created"
|
||||
except:
|
||||
raise RuntimeError("Whoa. new_EB created")
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
del_eb = dc.delete_EB
|
||||
|
|
@ -83,7 +83,7 @@ f = dc.new_F()
|
|||
|
||||
try:
|
||||
del_f = dc.delete_F
|
||||
print "Whoa. delete_F created"
|
||||
raise RuntimeError("Whoa. delete_F created")
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ g = dc.new_G()
|
|||
|
||||
try:
|
||||
del_g = dc.delete_G
|
||||
print "Whoa. delete_G created"
|
||||
raise RuntimeError("Whoa. delete_G created")
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue