summaryrefslogtreecommitdiff
path: root/Examples/test-suite/python
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/python')
-rw-r--r--Examples/test-suite/python/Makefile.in94
-rw-r--r--Examples/test-suite/python/autodoc_runme.py211
-rw-r--r--Examples/test-suite/python/cpp11_function_objects_runme.py11
-rw-r--r--Examples/test-suite/python/cpp11_strongly_typed_enumerations_runme.py164
-rw-r--r--Examples/test-suite/python/default_args_runme.py152
-rw-r--r--Examples/test-suite/python/default_constructor_runme.py6
-rw-r--r--Examples/test-suite/python/director_exception_runme.py19
-rw-r--r--Examples/test-suite/python/director_keywords_runme.py5
-rw-r--r--Examples/test-suite/python/director_property_runme.py18
-rw-r--r--Examples/test-suite/python/exception_order_runme.py2
-rw-r--r--Examples/test-suite/python/import_nomodule_runme.py5
-rw-r--r--Examples/test-suite/python/kwargs_feature_runme.py4
-rw-r--r--Examples/test-suite/python/li_std_except_as_class_runme.py24
-rw-r--r--Examples/test-suite/python/li_std_string_extra_runme.py13
-rw-r--r--Examples/test-suite/python/li_std_wstring_runme.py15
-rw-r--r--Examples/test-suite/python/nested_template_base_runme.py13
-rw-r--r--Examples/test-suite/python/preproc_runme.py2
-rw-r--r--Examples/test-suite/python/python_abstractbase_runme3.py2
-rw-r--r--Examples/test-suite/python/python_append_runme.py9
-rw-r--r--Examples/test-suite/python/python_threads_runme.py10
-rw-r--r--Examples/test-suite/python/smart_pointer_const_overload_runme.py2
-rw-r--r--Examples/test-suite/python/threads_exception_runme.py19
-rw-r--r--Examples/test-suite/python/unicode_strings_runme.py14
23 files changed, 632 insertions, 182 deletions
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index e7db32fb7..82a0e9db1 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -10,10 +10,13 @@ endif
LANGUAGE = python
PYTHON = $(PYBIN)
+PEP8 = @PEP8@
+PEP8_FLAGS = --ignore=E402,E501,E30,W291,W391
#*_runme.py for Python 2.x, *_runme3.py for Python 3.x
PY2SCRIPTSUFFIX = _runme.py
PY3SCRIPTSUFFIX = _runme3.py
+PY2TO3 = 2to3 -x import
ifeq (,$(PY3))
SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX)
@@ -25,10 +28,6 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
-
-PY2TO3 = 2to3 -x import
-
-
CPP_TEST_CASES += \
argcargvtest \
callback \
@@ -41,7 +40,6 @@ CPP_TEST_CASES += \
inout \
inplaceadd \
input \
- kwargs_feature \
li_cstring \
li_cwstring \
li_factory \
@@ -88,82 +86,89 @@ C_TEST_CASES += \
include $(srcdir)/../common.mk
-BUILTIN_BROKEN = \
- default_constructor.cpptest \
- director_exception.cpptest \
- exception_order.cpptest \
- li_std_string_extra.cpptest \
- li_std_wstring.cpptest \
- python_abstractbase.cpptest \
- threads_exception.cpptest
-
-BUILTIN_NOT_BROKEN = $(filter-out $(BUILTIN_BROKEN),$(NOT_BROKEN_TEST_CASES))
-
-builtin-check : $(BUILTIN_NOT_BROKEN)
-
# Overridden variables here
-LIBS = -L.
+SCRIPTDIR = .
+LIBS = -L.
VALGRIND_OPT += --suppressions=pythonswig.supp
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
-%.cpptest:
+%.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:
+%.multicpptest:
+$(convert_testcase)
$(setup)
+$(swig_and_compile_multi_cpp)
+ $(check_pep8_multi_cpp)
$(run_testcase)
-# Call 2to3 to generate Python 3.x test from the Python 2.x's *_runme.py file
-%$(PY3SCRIPTSUFFIX): %$(PY2SCRIPTSUFFIX)
- cp $< $@
- $(PY2TO3) -w $@ >/dev/null 2>&1
-
# 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.
-run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
+py_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
+py2_runme = $(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
+py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
+
+check_pep8 = \
+ if [ -n "$(PEP8)" ]; then \
+ $(PEP8) $(PEP8_FLAGS) $(SCRIPTPREFIX)$*.py;\
+ fi
+
+check_pep8_multi_cpp = \
+ if [ -n "$(PEP8)" ]; then \
+ for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
+ $(PEP8) $(PEP8_FLAGS) $$f.py; \
+ done \
+ fi
-py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
-py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
+run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(py_runme)
run_testcase = \
- if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+ if [ -f $(SCRIPTDIR)/$(py_runme) ]; then \
$(run_python);\
fi
-ifeq (,$(PY3))
+# No copying/conversion needed for in-source-tree Python 2 scripts
+ifeq ($(SCRIPTDIR)|$(SCRIPTSUFFIX),$(srcdir)|$(PY2SCRIPTSUFFIX))
convert_testcase =
else
+
convert_testcase = \
- if [ -f $(py2_runme) ]; then \
- $(MAKE) -f $(srcdir)/Makefile $(py3_runme); \
+ if [ -f $(srcdir)/$(py2_runme) ]; then \
+ $(MAKE) $(SCRIPTDIR)/$(py_runme); \
fi
+
+$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX)
+ test x$< = x$@ || cp $< $@ || exit 1
+ test x$(PY3) = x || $(PY2TO3) -w $@ >/dev/null 2>&1 || exit 1
+
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;
- @#We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
- @if [ -f $(py2_runme) ]; then rm -f $(py3_runme) $(py3_runme).bak; fi
+ @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)/$(py2_runme); fi
clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" python_clean
rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
rm -f clientdata_prop_a.py clientdata_prop_b.py import_stl_a.py import_stl_b.py
rm -f imports_a.py imports_b.py mod_a.py mod_b.py multi_import_a.py
@@ -172,12 +177,12 @@ clean:
cvsignore:
@echo '*wrap* *.pyc *.so *.dll *.exp *.lib'
@echo Makefile
- @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.py; done
- @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.py CVS/Entries ; then echo $${i}_runme.py; fi; done
- @echo clientdata_prop_a.py
- @echo clientdata_prop_b.py
- @echo imports_a.py
- @echo imports_b.py
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.py; done
+ @for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.py CVS/Entries ; then echo $${i}_runme.py; fi; done
+ @echo clientdata_prop_a.py
+ @echo clientdata_prop_b.py
+ @echo imports_a.py
+ @echo imports_b.py
@echo mod_a.py mod_b.py
@echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
@echo template_typedef_import.py
@@ -185,9 +190,8 @@ cvsignore:
hugemod_runme = hugemod$(SCRIPTPREFIX)
hugemod:
- perl hugemod.pl $(hugemod_runme)
+ perl hugemod.pl $(hugemod_runme)
$(MAKE) hugemod_a.cpptest
$(MAKE) hugemod_b.cpptest
sh -c "time $(PYTHON) $(hugemod_runme)"
sh -c "time $(PYTHON) $(hugemod_runme)"
-
diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py
index 5776ad3ef..756b85904 100644
--- a/Examples/test-suite/python/autodoc_runme.py
+++ b/Examples/test-suite/python/autodoc_runme.py
@@ -1,15 +1,26 @@
from autodoc import *
import sys
-def check(got, expected):
- if expected != got:
- raise RuntimeError("\n" + "Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]")
+def check(got, expected, expected_builtin = None, skip = False):
+ if not skip:
+ expect = expected
+ if is_python_builtin() and expected_builtin != None:
+ expect = expected_builtin
+ if expect != got:
+ raise RuntimeError("\n" + "Expected: [" + str(expect) + "]\n" + "Got : [" + str(got) + "]")
-check(A.__doc__, "Proxy of C++ A class")
+skip = True # skip builtin check - the autodoc is missing, but it probably should not be
+
+check(A.__doc__, "Proxy of C++ A class", "::A")
check(A.funk.__doc__, "just a string")
-check(A.func0.__doc__, "func0(self, arg2, hello) -> int")
-check(A.func1.__doc__, "func1(A self, short arg2, Tuple hello) -> int")
-check(A.func2.__doc__, "\n"
+check(A.func0.__doc__,
+"func0(self, arg2, hello) -> int",
+"func0(arg2, hello) -> int")
+check(A.func1.__doc__,
+"func1(A self, short arg2, Tuple hello) -> int",
+"func1(short arg2, Tuple hello) -> int")
+check(A.func2.__doc__,
+"\n"
" func2(self, arg2, hello) -> int\n"
"\n"
" Parameters:\n"
@@ -17,8 +28,18 @@ check(A.func2.__doc__, "\n"
" hello: int tuple[2]\n"
"\n"
" "
+,
+"\n"
+"func2(arg2, hello) -> int\n"
+"\n"
+"Parameters:\n"
+" arg2: short\n"
+" hello: int tuple[2]\n"
+"\n"
+""
)
-check(A.func3.__doc__, "\n"
+check(A.func3.__doc__,
+"\n"
" func3(A self, short arg2, Tuple hello) -> int\n"
"\n"
" Parameters:\n"
@@ -26,19 +47,41 @@ check(A.func3.__doc__, "\n"
" hello: int tuple[2]\n"
"\n"
" "
+,
+"\n"
+"func3(short arg2, Tuple hello) -> int\n"
+"\n"
+"Parameters:\n"
+" arg2: short\n"
+" hello: int tuple[2]\n"
+"\n"
+""
)
-check(A.func0default.__doc__, "\n"
+check(A.func0default.__doc__,
+"\n"
" func0default(self, e, arg3, hello, f=2) -> int\n"
" func0default(self, e, arg3, hello) -> int\n"
" "
+,
+"\n"
+"func0default(e, arg3, hello, f=2) -> int\n"
+"func0default(e, arg3, hello) -> int\n"
+""
)
-check(A.func1default.__doc__, "\n"
+check(A.func1default.__doc__,
+"\n"
" func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
" func1default(A self, A e, short arg3, Tuple hello) -> int\n"
" "
+,
+"\n"
+"func1default(A e, short arg3, Tuple hello, double f=2) -> int\n"
+"func1default(A e, short arg3, Tuple hello) -> int\n"
+""
)
-check(A.func2default.__doc__, "\n"
+check(A.func2default.__doc__,
+"\n"
" func2default(self, e, arg3, hello, f=2) -> int\n"
"\n"
" Parameters:\n"
@@ -55,8 +98,27 @@ check(A.func2default.__doc__, "\n"
" hello: int tuple[2]\n"
"\n"
" "
+,
+"\n"
+"func2default(e, arg3, hello, f=2) -> int\n"
+"\n"
+"Parameters:\n"
+" e: A *\n"
+" arg3: short\n"
+" hello: int tuple[2]\n"
+" f: double\n"
+"\n"
+"func2default(e, arg3, hello) -> int\n"
+"\n"
+"Parameters:\n"
+" e: A *\n"
+" arg3: short\n"
+" hello: int tuple[2]\n"
+"\n"
+""
)
-check(A.func3default.__doc__, "\n"
+check(A.func3default.__doc__,
+"\n"
" func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
"\n"
" Parameters:\n"
@@ -73,19 +135,50 @@ check(A.func3default.__doc__, "\n"
" hello: int tuple[2]\n"
"\n"
" "
+,
+"\n"
+"func3default(A e, short arg3, Tuple hello, double f=2) -> int\n"
+"\n"
+"Parameters:\n"
+" e: A *\n"
+" arg3: short\n"
+" hello: int tuple[2]\n"
+" f: double\n"
+"\n"
+"func3default(A e, short arg3, Tuple hello) -> int\n"
+"\n"
+"Parameters:\n"
+" e: A *\n"
+" arg3: short\n"
+" hello: int tuple[2]\n"
+"\n"
+""
)
-check(A.func0static.__doc__, "\n"
+check(A.func0static.__doc__,
+"\n"
" func0static(e, arg2, hello, f=2) -> int\n"
" func0static(e, arg2, hello) -> int\n"
" "
+,
+"\n"
+"func0static(e, arg2, hello, f=2) -> int\n"
+"func0static(e, arg2, hello) -> int\n"
+""
)
-check(A.func1static.__doc__, "\n"
+check(A.func1static.__doc__,
+"\n"
" func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
" func1static(A e, short arg2, Tuple hello) -> int\n"
" "
+,
+"\n"
+"func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
+"func1static(A e, short arg2, Tuple hello) -> int\n"
+""
)
-check(A.func2static.__doc__, "\n"
+check(A.func2static.__doc__,
+"\n"
" func2static(e, arg2, hello, f=2) -> int\n"
"\n"
" Parameters:\n"
@@ -102,8 +195,27 @@ check(A.func2static.__doc__, "\n"
" hello: int tuple[2]\n"
"\n"
" "
+,
+"\n"
+"func2static(e, arg2, hello, f=2) -> int\n"
+"\n"
+"Parameters:\n"
+" e: A *\n"
+" arg2: short\n"
+" hello: int tuple[2]\n"
+" f: double\n"
+"\n"
+"func2static(e, arg2, hello) -> int\n"
+"\n"
+"Parameters:\n"
+" e: A *\n"
+" arg2: short\n"
+" hello: int tuple[2]\n"
+"\n"
+""
)
-check(A.func3static.__doc__, "\n"
+check(A.func3static.__doc__,
+"\n"
" func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
" Parameters:\n"
@@ -120,31 +232,65 @@ check(A.func3static.__doc__, "\n"
" hello: int tuple[2]\n"
"\n"
" "
+,
+"\n"
+"func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
+"\n"
+"Parameters:\n"
+" e: A *\n"
+" arg2: short\n"
+" hello: int tuple[2]\n"
+" f: double\n"
+"\n"
+"func3static(A e, short arg2, Tuple hello) -> int\n"
+"\n"
+"Parameters:\n"
+" e: A *\n"
+" arg2: short\n"
+" hello: int tuple[2]\n"
+"\n"
+""
)
if sys.version_info[0:2] > (2, 4):
# Python 2.4 does not seem to work
- check(A.variable_a.__doc__, "A_variable_a_get(self) -> int")
- check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int")
- check(A.variable_c.__doc__, "\n"
+ check(A.variable_a.__doc__,
+ "A_variable_a_get(self) -> int",
+ "A.variable_a"
+ )
+ check(A.variable_b.__doc__,
+ "A_variable_b_get(A self) -> int",
+ "A.variable_b"
+ )
+ check(A.variable_c.__doc__,
+ "\n"
"A_variable_c_get(self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n"
"\n"
+ ,
+ "A.variable_c"
)
- check(A.variable_d.__doc__, "\n"
+ check(A.variable_d.__doc__,
+ "\n"
"A_variable_d_get(A self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n"
"\n"
+ ,
+ "A.variable_d"
)
-check(B.__doc__, "Proxy of C++ B class")
-check(C.__init__.__doc__, "__init__(self, a, b, h) -> C")
-check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D")
-check(E.__init__.__doc__, "\n"
+check(B.__doc__,
+"Proxy of C++ B class",
+"::B"
+)
+check(C.__init__.__doc__, "__init__(self, a, b, h) -> C", None, skip)
+check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D", None, skip)
+check(E.__init__.__doc__,
+"\n"
" __init__(self, a, b, h) -> E\n"
"\n"
" Parameters:\n"
@@ -153,8 +299,10 @@ check(E.__init__.__doc__, "\n"
" h: enum Hola\n"
"\n"
" "
+, None, skip
)
-check(F.__init__.__doc__, "\n"
+check(F.__init__.__doc__,
+"\n"
" __init__(F self, int a, int b, Hola h) -> F\n"
"\n"
" Parameters:\n"
@@ -163,14 +311,23 @@ check(F.__init__.__doc__, "\n"
" h: enum Hola\n"
"\n"
" "
+, None, skip
)
-check(B.funk.__doc__, "funk(B self, int c, int d) -> int")
+check(B.funk.__doc__,
+"funk(B self, int c, int d) -> int",
+"funk(int c, int d) -> int")
check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int")
-check(funkdefaults.__doc__, "\n"
+check(funkdefaults.__doc__,
+"\n"
" funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
" funkdefaults(A e, short arg2, int c, int d) -> int\n"
" "
+,
+"\n"
+"funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
+"funkdefaults(A e, short arg2, int c, int d) -> int\n"
+""
)
check(func_input.__doc__, "func_input(int * INPUT) -> int")
diff --git a/Examples/test-suite/python/cpp11_function_objects_runme.py b/Examples/test-suite/python/cpp11_function_objects_runme.py
index aac7f9c5f..5a63b632b 100644
--- a/Examples/test-suite/python/cpp11_function_objects_runme.py
+++ b/Examples/test-suite/python/cpp11_function_objects_runme.py
@@ -1,6 +1,13 @@
import cpp11_function_objects
import sys
+class Test1(cpp11_function_objects.Test):
+ def __init__(self):
+ cpp11_function_objects.Test.__init__(self)
+
+ def __call__(self, a, b):
+ self.value = a * b
+
t = cpp11_function_objects.Test()
if t.value != 0:
raise RuntimeError("Runtime cpp11_function_objects failed. t.value should be 0, but is " + str(t.value))
@@ -10,3 +17,7 @@ t(1,2) # adds numbers and sets value
if t.value != 3:
raise RuntimeError("Runtime cpp11_function_objects failed. t.value not changed - should be 3, but is " + str(t.value))
+t2 = Test1()
+a = cpp11_function_objects.testit1(t2, 4,3)
+if a != 12:
+ raise RuntimeError("Runtime cpp11_function_objects failed. t.value not changed - should be 12, but is " + str(a))
diff --git a/Examples/test-suite/python/cpp11_strongly_typed_enumerations_runme.py b/Examples/test-suite/python/cpp11_strongly_typed_enumerations_runme.py
new file mode 100644
index 000000000..6509ba873
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_strongly_typed_enumerations_runme.py
@@ -0,0 +1,164 @@
+from cpp11_strongly_typed_enumerations import *
+
+def enumCheck(actual, expected):
+ if actual != expected:
+ raise RuntimeError("Enum value mismatch. Expected " + str(expected) + " Actual: " + str(actual))
+ return expected + 1
+
+val = 0
+val = enumCheck(Enum1_Val1, val)
+val = enumCheck(Enum1_Val2, val)
+val = enumCheck(Enum1_Val3, 13)
+val = enumCheck(Enum1_Val4, val)
+val = enumCheck(Enum1_Val5a, 13)
+val = enumCheck(Enum1_Val6a, val)
+
+val = 0
+val = enumCheck(Enum2_Val1, val)
+val = enumCheck(Enum2_Val2, val)
+val = enumCheck(Enum2_Val3, 23)
+val = enumCheck(Enum2_Val4, val)
+val = enumCheck(Enum2_Val5b, 23)
+val = enumCheck(Enum2_Val6b, val)
+
+val = 0
+val = enumCheck(Val1, val)
+val = enumCheck(Val2, val)
+val = enumCheck(Val3, 43)
+val = enumCheck(Val4, val)
+
+val = 0
+val = enumCheck(Enum5_Val1, val)
+val = enumCheck(Enum5_Val2, val)
+val = enumCheck(Enum5_Val3, 53)
+val = enumCheck(Enum5_Val4, val)
+
+val = 0
+val = enumCheck(Enum6_Val1, val)
+val = enumCheck(Enum6_Val2, val)
+val = enumCheck(Enum6_Val3, 63)
+val = enumCheck(Enum6_Val4, val)
+
+val = 0
+val = enumCheck(Enum7td_Val1, val)
+val = enumCheck(Enum7td_Val2, val)
+val = enumCheck(Enum7td_Val3, 73)
+val = enumCheck(Enum7td_Val4, val)
+
+val = 0
+val = enumCheck(Enum8_Val1, val)
+val = enumCheck(Enum8_Val2, val)
+val = enumCheck(Enum8_Val3, 83)
+val = enumCheck(Enum8_Val4, val)
+
+val = 0
+val = enumCheck(Enum10_Val1, val)
+val = enumCheck(Enum10_Val2, val)
+val = enumCheck(Enum10_Val3, 103)
+val = enumCheck(Enum10_Val4, val)
+
+val = 0
+val = enumCheck(Class1.Enum12_Val1, 1121)
+val = enumCheck(Class1.Enum12_Val2, 1122)
+val = enumCheck(Class1.Enum12_Val3, val)
+val = enumCheck(Class1.Enum12_Val4, val)
+val = enumCheck(Class1.Enum12_Val5c, 1121)
+val = enumCheck(Class1.Enum12_Val6c, val)
+
+val = 0
+val = enumCheck(Class1.Val1, 1131)
+val = enumCheck(Class1.Val2, 1132)
+val = enumCheck(Class1.Val3, val)
+val = enumCheck(Class1.Val4, val)
+val = enumCheck(Class1.Val5d, 1131)
+val = enumCheck(Class1.Val6d, val)
+
+val = 0
+val = enumCheck(Class1.Enum14_Val1, 1141)
+val = enumCheck(Class1.Enum14_Val2, 1142)
+val = enumCheck(Class1.Enum14_Val3, val)
+val = enumCheck(Class1.Enum14_Val4, val)
+val = enumCheck(Class1.Enum14_Val5e, 1141)
+val = enumCheck(Class1.Enum14_Val6e, val)
+
+# Requires nested class support to work
+#val = 0
+#val = enumCheck(Class1.Struct1.Enum12_Val1, 3121)
+#val = enumCheck(Class1.Struct1.Enum12_Val2, 3122)
+#val = enumCheck(Class1.Struct1.Enum12_Val3, val)
+#val = enumCheck(Class1.Struct1.Enum12_Val4, val)
+#val = enumCheck(Class1.Struct1.Enum12_Val5f, 3121)
+#val = enumCheck(Class1.Struct1.Enum12_Val6f, val)
+#
+#val = 0
+#val = enumCheck(Class1.Struct1.Val1, 3131)
+#val = enumCheck(Class1.Struct1.Val2, 3132)
+#val = enumCheck(Class1.Struct1.Val3, val)
+#val = enumCheck(Class1.Struct1.Val4, val)
+#
+#val = 0
+#val = enumCheck(Class1.Struct1.Enum14_Val1, 3141)
+#val = enumCheck(Class1.Struct1.Enum14_Val2, 3142)
+#val = enumCheck(Class1.Struct1.Enum14_Val3, val)
+#val = enumCheck(Class1.Struct1.Enum14_Val4, val)
+#val = enumCheck(Class1.Struct1.Enum14_Val5g, 3141)
+#val = enumCheck(Class1.Struct1.Enum14_Val6g, val)
+
+val = 0
+val = enumCheck(Class2.Enum12_Val1, 2121)
+val = enumCheck(Class2.Enum12_Val2, 2122)
+val = enumCheck(Class2.Enum12_Val3, val)
+val = enumCheck(Class2.Enum12_Val4, val)
+val = enumCheck(Class2.Enum12_Val5h, 2121)
+val = enumCheck(Class2.Enum12_Val6h, val)
+
+val = 0
+val = enumCheck(Class2.Val1, 2131)
+val = enumCheck(Class2.Val2, 2132)
+val = enumCheck(Class2.Val3, val)
+val = enumCheck(Class2.Val4, val)
+val = enumCheck(Class2.Val5i, 2131)
+val = enumCheck(Class2.Val6i, val)
+
+val = 0
+val = enumCheck(Class2.Enum14_Val1, 2141)
+val = enumCheck(Class2.Enum14_Val2, 2142)
+val = enumCheck(Class2.Enum14_Val3, val)
+val = enumCheck(Class2.Enum14_Val4, val)
+val = enumCheck(Class2.Enum14_Val5j, 2141)
+val = enumCheck(Class2.Enum14_Val6j, val)
+
+# Requires nested class support to work
+#val = 0
+#val = enumCheck(Class2.Struct1.Enum12_Val1, 4121)
+#val = enumCheck(Class2.Struct1.Enum12_Val2, 4122)
+#val = enumCheck(Class2.Struct1.Enum12_Val3, val)
+#val = enumCheck(Class2.Struct1.Enum12_Val4, val)
+#val = enumCheck(Class2.Struct1.Enum12_Val5k, 4121)
+#val = enumCheck(Class2.Struct1.Enum12_Val6k, val)
+#
+#val = 0
+#val = enumCheck(Class2.Struct1.Val1, 4131)
+#val = enumCheck(Class2.Struct1.Val2, 4132)
+#val = enumCheck(Class2.Struct1.Val3, val)
+#val = enumCheck(Class2.Struct1.Val4, val)
+#val = enumCheck(Class2.Struct1.Val5l, 4131)
+#val = enumCheck(Class2.Struct1.Val6l, val)
+#
+#val = 0
+#val = enumCheck(Class2.Struct1.Enum14_Val1, 4141)
+#val = enumCheck(Class2.Struct1.Enum14_Val2, 4142)
+#val = enumCheck(Class2.Struct1.Enum14_Val3, val)
+#val = enumCheck(Class2.Struct1.Enum14_Val4, val)
+#val = enumCheck(Class2.Struct1.Enum14_Val5m, 4141)
+#val = enumCheck(Class2.Struct1.Enum14_Val6m, val)
+
+class1 = Class1()
+enumCheck(class1.class1Test1(Enum1_Val5a), 13)
+enumCheck(class1.class1Test2(Class1.Enum12_Val5c), 1121)
+#enumCheck(class1.class1Test3(Class1.Struct1.Enum12_Val5f), 3121)
+
+enumCheck(globalTest1(Enum1_Val5a), 13)
+enumCheck(globalTest2(Class1.Enum12_Val5c), 1121)
+#enumCheck(globalTest3(Class1.Struct1.Enum12_Val5f), 3121)
+
diff --git a/Examples/test-suite/python/default_args_runme.py b/Examples/test-suite/python/default_args_runme.py
index 091a92376..f24e825ad 100644
--- a/Examples/test-suite/python/default_args_runme.py
+++ b/Examples/test-suite/python/default_args_runme.py
@@ -1,64 +1,90 @@
-import default_args
-
-
-if default_args.Statics_staticMethod() != 60:
- raise RuntimeError
-
-if default_args.cfunc1(1) != 2:
- raise RuntimeError
-
-if default_args.cfunc2(1) != 3:
- raise RuntimeError
-
-if default_args.cfunc3(1) != 4:
- raise RuntimeError
-
-
-f = default_args.Foo()
-
-f.newname()
-f.newname(1)
-
-
-try:
- f = default_args.Foo(1)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::Foo ignore is not working"
-
-try:
- f = default_args.Foo(1,2)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::Foo ignore is not working"
-
-try:
- f = default_args.Foo(1,2,3)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::Foo ignore is not working"
-
-try:
- m = f.meth(1)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::meth ignore is not working"
-
-try:
- m = f.meth(1,2)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::meth ignore is not working"
-
-try:
- m = f.meth(1,2,3)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::meth ignore is not working"
+# Note that this test is also used by python_default_args_runme.py hence the use of __main__ and the run function
+
+def run(module_name):
+ default_args = __import__(module_name)
+ ec = default_args.EnumClass()
+ if not ec.blah():
+ raise RuntimeError("EnumClass::blah() default arguments don't work")
+
+ de = default_args.DerivedEnumClass()
+ de.accelerate()
+ de.accelerate(default_args.EnumClass.SLOW)
+
+ if default_args.Statics_staticMethod() != 60:
+ raise RuntimeError
+
+ if default_args.cfunc1(1) != 2:
+ raise RuntimeError
+
+ if default_args.cfunc2(1) != 3:
+ raise RuntimeError
+
+ if default_args.cfunc3(1) != 4:
+ raise RuntimeError
+
+
+ f = default_args.Foo()
+
+ f.newname()
+ f.newname(1)
+
+
+ try:
+ f = default_args.Foo(1)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::Foo ignore is not working")
+
+ try:
+ f = default_args.Foo(1,2)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::Foo ignore is not working")
+
+ try:
+ f = default_args.Foo(1,2,3)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::Foo ignore is not working")
+
+ try:
+ m = f.meth(1)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::meth ignore is not working")
+
+ try:
+ m = f.meth(1,2)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::meth ignore is not working")
+
+ try:
+ m = f.meth(1,2,3)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::meth ignore is not working")
+
+ if default_args.Klass.inc(100, default_args.Klass(22)).val != 122:
+ raise RuntimeError("Klass::inc failed")
+
+ if default_args.Klass.inc(100).val != 99:
+ raise RuntimeError("Klass::inc failed")
+
+ if default_args.Klass.inc().val != 0:
+ raise RuntimeError("Klass::inc failed")
+
+ default_args.trickyvalue1(10); default_args.trickyvalue1(10, 10)
+ default_args.trickyvalue2(10); default_args.trickyvalue2(10, 10)
+ default_args.trickyvalue3(10); default_args.trickyvalue3(10, 10)
+ default_args.seek(); default_args.seek(10)
+
+if __name__=="__main__":
+ run('default_args')
diff --git a/Examples/test-suite/python/default_constructor_runme.py b/Examples/test-suite/python/default_constructor_runme.py
index 59b130559..e6532031b 100644
--- a/Examples/test-suite/python/default_constructor_runme.py
+++ b/Examples/test-suite/python/default_constructor_runme.py
@@ -1,8 +1,10 @@
+import _default_constructor
+
# This test is expected to fail with -builtin option.
# It uses the old static syntax (e.g., dc.new_A() rather than dc.A()),
# which is not provided with the -builtin option.
-
-import _default_constructor
+if _default_constructor.is_python_builtin():
+ exit(0)
dc = _default_constructor
diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py
index 510845a5a..de3ef22a5 100644
--- a/Examples/test-suite/python/director_exception_runme.py
+++ b/Examples/test-suite/python/director_exception_runme.py
@@ -68,14 +68,13 @@ if not ok:
# This is expected to fail with -builtin option
# Throwing builtin classes as exceptions not supported
-try:
- raise Exception2()
-except Exception2:
- pass
+if not is_python_builtin():
+ try:
+ raise Exception2()
+ except Exception2:
+ pass
-# This is expected to fail with -builtin option
-# Throwing builtin classes as exceptions not supported
-try:
- raise Exception1()
-except Exception1:
- pass
+ try:
+ raise Exception1()
+ except Exception1:
+ pass
diff --git a/Examples/test-suite/python/director_keywords_runme.py b/Examples/test-suite/python/director_keywords_runme.py
new file mode 100644
index 000000000..03a50206a
--- /dev/null
+++ b/Examples/test-suite/python/director_keywords_runme.py
@@ -0,0 +1,5 @@
+from director_keywords import *
+
+f = Foo()
+f.check_self(20)
+
diff --git a/Examples/test-suite/python/director_property_runme.py b/Examples/test-suite/python/director_property_runme.py
new file mode 100644
index 000000000..303e53b67
--- /dev/null
+++ b/Examples/test-suite/python/director_property_runme.py
@@ -0,0 +1,18 @@
+import director_property
+
+class PyFoo(director_property.Foo):
+ a = property(director_property.Foo.getA, director_property.Foo.setA)
+
+ def ping(self):
+ return "PyFoo::ping()"
+
+
+foo = PyFoo()
+
+foo.setA("BLABLA")
+if foo.getA() != "BLABLA":
+ raise RuntimeError
+
+foo.a = "BIBI"
+if foo.a != "BIBI":
+ raise RuntimeError
diff --git a/Examples/test-suite/python/exception_order_runme.py b/Examples/test-suite/python/exception_order_runme.py
index 38b53eb0c..8f095eb98 100644
--- a/Examples/test-suite/python/exception_order_runme.py
+++ b/Examples/test-suite/python/exception_order_runme.py
@@ -2,6 +2,8 @@ from exception_order import *
# This test is expected to fail with -builtin option.
# Throwing builtin classes as exceptions not supported
+if is_python_builtin():
+ exit(0)
a = A()
diff --git a/Examples/test-suite/python/import_nomodule_runme.py b/Examples/test-suite/python/import_nomodule_runme.py
index ba0abfd9a..efcff9c48 100644
--- a/Examples/test-suite/python/import_nomodule_runme.py
+++ b/Examples/test-suite/python/import_nomodule_runme.py
@@ -1,5 +1,10 @@
from import_nomodule import *
+# This test is expected to fail with -builtin option.
+# The base class is needed for the builtin class hierarchy
+if is_python_builtin():
+ exit(0)
+
f = create_Foo()
test1(f,42)
delete_Foo(f)
diff --git a/Examples/test-suite/python/kwargs_feature_runme.py b/Examples/test-suite/python/kwargs_feature_runme.py
index 5539e211d..7792e2e06 100644
--- a/Examples/test-suite/python/kwargs_feature_runme.py
+++ b/Examples/test-suite/python/kwargs_feature_runme.py
@@ -44,10 +44,10 @@ if BarInt_sbar(b=2) != 3:
if templatedfunction(b=2) != 3:
raise RuntimeError
-if foo(a=1,b=2) != 3:
+if foo_fn(a=1,b=2) != 3:
raise RuntimeError
-if foo(b=2) != 3:
+if foo_fn(b=2) != 3:
raise RuntimeError
diff --git a/Examples/test-suite/python/li_std_except_as_class_runme.py b/Examples/test-suite/python/li_std_except_as_class_runme.py
index 386a878bf..a86e7a562 100644
--- a/Examples/test-suite/python/li_std_except_as_class_runme.py
+++ b/Examples/test-suite/python/li_std_except_as_class_runme.py
@@ -1,9 +1,19 @@
from li_std_except_as_class import *
-# std::domain_error hierarchy
-try: test_domain_error()
-except domain_error: pass
-try: test_domain_error()
-except logic_error: pass
-try: test_domain_error()
-except exception: pass
+# This test is expected to fail with -builtin option.
+# Throwing builtin classes as exceptions not supported
+if is_python_builtin():
+ try: test_domain_error()
+ except RuntimeError: pass
+ try: test_domain_error()
+ except RuntimeError: pass
+ try: test_domain_error()
+ except RuntimeError: pass
+else:
+ # std::domain_error hierarchy
+ try: test_domain_error()
+ except domain_error: pass
+ try: test_domain_error()
+ except logic_error: pass
+ try: test_domain_error()
+ except exception: pass
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 9e9e3d2c3..503d09eb5 100644
--- a/Examples/test-suite/python/li_std_string_extra_runme.py
+++ b/Examples/test-suite/python/li_std_string_extra_runme.py
@@ -56,14 +56,13 @@ if a + " world" != "hello world":
# This is expected to fail with -builtin option
# Reverse operators not supported in builtin types
-if "hello" + b != "hello world":
- raise RuntimeError, "bad string mapping"
+if not li_std_string_extra.is_python_builtin():
+ if "hello" + b != "hello world":
+ raise RuntimeError, "bad string mapping"
-# This is expected to fail with -builtin option
-# Reverse operators not supported in builtin types
-c = "hello" + b
-if c.find_last_of("l") != 9:
- raise RuntimeError, "bad string mapping"
+ c = "hello" + b
+ if c.find_last_of("l") != 9:
+ raise RuntimeError, "bad string mapping"
s = "hello world"
diff --git a/Examples/test-suite/python/li_std_wstring_runme.py b/Examples/test-suite/python/li_std_wstring_runme.py
index fecc527e0..a467ae8bc 100644
--- a/Examples/test-suite/python/li_std_wstring_runme.py
+++ b/Examples/test-suite/python/li_std_wstring_runme.py
@@ -60,13 +60,14 @@ if a + " world" != "hello world":
raise RuntimeError("bad string mapping")
# This is expected to fail if -builtin is used
-if "hello" + b != "hello world":
- raise RuntimeError("bad string mapping")
-
-# This is expected to fail if -builtin is used
-c = "hello" + b
-if c.find_last_of("l") != 9:
- raise RuntimeError("bad string mapping")
+# Reverse operators not supported in builtin types
+if not li_std_wstring.is_python_builtin():
+ if "hello" + b != "hello world":
+ raise RuntimeError("bad string mapping")
+
+ c = "hello" + b
+ if c.find_last_of("l") != 9:
+ raise RuntimeError("bad string mapping")
s = "hello world"
diff --git a/Examples/test-suite/python/nested_template_base_runme.py b/Examples/test-suite/python/nested_template_base_runme.py
new file mode 100644
index 000000000..3d54b8391
--- /dev/null
+++ b/Examples/test-suite/python/nested_template_base_runme.py
@@ -0,0 +1,13 @@
+from nested_template_base import *
+
+
+ois = InnerS(123);
+oic = InnerC();
+
+# Check base method is available
+if (oic.outer(ois).val != 123):
+ raise RuntimeError("Wrong value calling outer");
+
+# Check non-derived class using base class
+if (oic.innerc().outer(ois).val != 123):
+ raise RuntimeError("Wrong value calling innerc");
diff --git a/Examples/test-suite/python/preproc_runme.py b/Examples/test-suite/python/preproc_runme.py
index c989294b6..3049f00ab 100644
--- a/Examples/test-suite/python/preproc_runme.py
+++ b/Examples/test-suite/python/preproc_runme.py
@@ -12,3 +12,5 @@ if preproc.defined != 1:
if 2*preproc.one != preproc.two:
raise RuntimeError
+if preproc.methodX(99) != 199:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/python_abstractbase_runme3.py b/Examples/test-suite/python/python_abstractbase_runme3.py
index 94dee3ff7..9b189964d 100644
--- a/Examples/test-suite/python/python_abstractbase_runme3.py
+++ b/Examples/test-suite/python/python_abstractbase_runme3.py
@@ -3,6 +3,8 @@ from collections import *
# This is expected to fail with -builtin option
# Builtin types can't inherit from pure-python abstract bases
+if is_python_builtin():
+ exit(0)
assert issubclass(Mapii, MutableMapping)
assert issubclass(Multimapii, MutableMapping)
diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py
index 41cebad58..54d7a3e00 100644
--- a/Examples/test-suite/python/python_append_runme.py
+++ b/Examples/test-suite/python/python_append_runme.py
@@ -1,11 +1,16 @@
from python_append import *
+
+# test not relevant for -builtin
+if is_python_builtin():
+ exit(0)
+
t=Test()
t.func()
t.static_func()
if grabpath() != os.path.dirname(mypath):
- raise RuntimeError
+ raise RuntimeError("grabpath failed")
if grabstaticpath() != os.path.basename(mypath):
- raise RuntimeError
+ raise RuntimeError("grabstaticpath failed")
diff --git a/Examples/test-suite/python/python_threads_runme.py b/Examples/test-suite/python/python_threads_runme.py
new file mode 100644
index 000000000..d00e2458f
--- /dev/null
+++ b/Examples/test-suite/python/python_threads_runme.py
@@ -0,0 +1,10 @@
+from python_threads import *
+
+action = ActionGroup()
+count = 1
+for child in action.GetActionList():
+ if child.val != count:
+ raise RuntimeError("Expected: " + str(count) + " got: " + str(child.val))
+ count = count + 1
+
+# Was seg faulting at the end here
diff --git a/Examples/test-suite/python/smart_pointer_const_overload_runme.py b/Examples/test-suite/python/smart_pointer_const_overload_runme.py
index f1be315a5..098e5b4c3 100644
--- a/Examples/test-suite/python/smart_pointer_const_overload_runme.py
+++ b/Examples/test-suite/python/smart_pointer_const_overload_runme.py
@@ -56,7 +56,7 @@ def test(b, f):
raise RuntimeError
# Test static method
- b.stat()
+ b.statMethod()
if f.access != CONST_ACCESS:
raise RuntimeError
diff --git a/Examples/test-suite/python/threads_exception_runme.py b/Examples/test-suite/python/threads_exception_runme.py
index d4b8855fc..6fe6947ec 100644
--- a/Examples/test-suite/python/threads_exception_runme.py
+++ b/Examples/test-suite/python/threads_exception_runme.py
@@ -20,15 +20,16 @@ except RuntimeError,e:
# This is expected fail with -builtin option
# Throwing builtin classes as exceptions not supported
-try:
- t.hosed()
-except threads_exception.Exc,e:
- code = e.code
- if code != 42:
- raise RuntimeError, "bad... code: %d" % code
- msg = e.msg
- if msg != "Hosed":
- raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg))
+if not threads_exception.is_python_builtin():
+ try:
+ t.hosed()
+ except threads_exception.Exc,e:
+ code = e.code
+ if code != 42:
+ raise RuntimeError, "bad... code: %d" % code
+ msg = e.msg
+ if msg != "Hosed":
+ raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg))
for i in range(1,4):
try:
diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py
new file mode 100644
index 000000000..e1fc7adec
--- /dev/null
+++ b/Examples/test-suite/python/unicode_strings_runme.py
@@ -0,0 +1,14 @@
+import sys
+
+import unicode_strings
+
+# The 'u' string prefix isn't valid in Python 3.0 - 3.2 and is redundant
+# in 3.3+. Since this file is run through 2to3 before testing, though,
+# mark this as a unicode string in 2.x so it'll become a str in 3.x.
+test_string = u'h\udce9llo w\u00f6rld'
+
+if sys.version_info[0:2] >= (3, 1):
+ if unicode_strings.non_utf8_c_str() != test_string:
+ raise ValueError('Test comparison mismatch')
+ if unicode_strings.non_utf8_std_string() != test_string:
+ raise ValueError('Test comparison mismatch')