diff --git a/Examples/test-suite/python/abstract_access_runme.py b/Examples/test-suite/python/abstract_access_runme.py index 55638e40e..8abce98ae 100644 --- a/Examples/test-suite/python/abstract_access_runme.py +++ b/Examples/test-suite/python/abstract_access_runme.py @@ -2,5 +2,4 @@ import abstract_access d = abstract_access.D() if d.do_x() != 1: - raise RuntimeError - + raise RuntimeError diff --git a/Examples/test-suite/python/abstract_typedef2_runme.py b/Examples/test-suite/python/abstract_typedef2_runme.py index 2a11d1944..ef6f415dd 100644 --- a/Examples/test-suite/python/abstract_typedef2_runme.py +++ b/Examples/test-suite/python/abstract_typedef2_runme.py @@ -1,8 +1,3 @@ -from abstract_typedef2 import * +from abstract_typedef2 import * a = A_UF() - - - - - diff --git a/Examples/test-suite/python/abstract_typedef_runme.py b/Examples/test-suite/python/abstract_typedef_runme.py index 15d70aa42..d69134f2e 100644 --- a/Examples/test-suite/python/abstract_typedef_runme.py +++ b/Examples/test-suite/python/abstract_typedef_runme.py @@ -1,11 +1,8 @@ -from abstract_typedef import * +from abstract_typedef import * e = Engine() a = A() - + if a.write(e) != 1: - raise RuntimeError - - - + raise RuntimeError diff --git a/Examples/test-suite/python/argcargvtest_runme.py b/Examples/test-suite/python/argcargvtest_runme.py index 047ea9551..38843b932 100644 --- a/Examples/test-suite/python/argcargvtest_runme.py +++ b/Examples/test-suite/python/argcargvtest_runme.py @@ -1,27 +1,26 @@ from argcargvtest import * -largs=['hi','hola','hello'] +largs = ['hi', 'hola', 'hello'] if mainc(largs) != 3: - raise RuntimeError("bad main typemap") + raise RuntimeError("bad main typemap") -targs=('hi','hola') -if mainv(targs,1) != 'hola': - print(mainv(targs,1)) - raise RuntimeError("bad main typemap") +targs = ('hi', 'hola') +if mainv(targs, 1) != 'hola': + print(mainv(targs, 1)) + raise RuntimeError("bad main typemap") -targs=('hi', 'hola') -if mainv(targs,1) != 'hola': - raise RuntimeError("bad main typemap") +targs = ('hi', 'hola') +if mainv(targs, 1) != 'hola': + raise RuntimeError("bad main typemap") try: - error = 0 - mainv('hello',1) - error = 1 + error = 0 + mainv('hello', 1) + error = 1 except TypeError: - pass + pass if error: - raise RuntimeError("bad main typemap") - + raise RuntimeError("bad main typemap") initializeApp(largs) diff --git a/Examples/test-suite/python/array_member_runme.py b/Examples/test-suite/python/array_member_runme.py index 95cf03b44..de6e0f3e7 100644 --- a/Examples/test-suite/python/array_member_runme.py +++ b/Examples/test-suite/python/array_member_runme.py @@ -3,19 +3,16 @@ from array_member import * f = Foo() f.data = cvar.global_data -for i in range(0,8): - if get_value(f.data,i) != get_value(cvar.global_data,i): +for i in range(0, 8): + if get_value(f.data, i) != get_value(cvar.global_data, i): raise RuntimeError, "Bad array assignment" -for i in range(0,8): - set_value(f.data,i,-i) +for i in range(0, 8): + set_value(f.data, i, -i) cvar.global_data = f.data -for i in range(0,8): - if get_value(f.data,i) != get_value(cvar.global_data,i): +for i in range(0, 8): + if get_value(f.data, i) != get_value(cvar.global_data, i): raise RuntimeError, "Bad array assignment" - - - diff --git a/Examples/test-suite/python/arrays_global_runme.py b/Examples/test-suite/python/arrays_global_runme.py index ab7fd6a41..fa3b9f2ec 100644 --- a/Examples/test-suite/python/arrays_global_runme.py +++ b/Examples/test-suite/python/arrays_global_runme.py @@ -2,19 +2,19 @@ import arrays_global arrays_global.cvar.array_i = arrays_global.cvar.array_const_i -from arrays_global import * +from arrays_global import * BeginString_FIX44a cvar.BeginString_FIX44b BeginString_FIX44c cvar.BeginString_FIX44d cvar.BeginString_FIX44d -cvar.BeginString_FIX44b ="12"'\0'"45" +cvar.BeginString_FIX44b = "12"'\0'"45" cvar.BeginString_FIX44b cvar.BeginString_FIX44d cvar.BeginString_FIX44e BeginString_FIX44f -test_a("hello","hi","chello","chi") +test_a("hello", "hi", "chello", "chi") -test_b("1234567","hi") +test_b("1234567", "hi") diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index 9b493bb43..f5b6b7ce6 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -1,341 +1,332 @@ from autodoc import * import sys -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) + "]") + +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) + "]") + def is_new_style_class(cls): - return hasattr(cls, "__class__") + return hasattr(cls, "__class__") if not is_new_style_class(A): - # Missing static methods make this hard to test... skip if -classic is used! - sys.exit(0) + # Missing static methods make this hard to test... skip if -classic is + # used! + sys.exit(0) -skip = True # skip builtin check - the autodoc is missing, but it probably should not be +# skip builtin check - the autodoc is missing, but it probably should not be +skip = True 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", -"func0(arg2, hello) -> int") + "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") + "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" -" arg2: short\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" -"" -) + "\n" + " func2(self, arg2, hello) -> int\n" + "\n" + " Parameters:\n" + " arg2: short\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" -" func3(A self, short arg2, Tuple hello) -> int\n" -"\n" -" Parameters:\n" -" arg2: short\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" -"" -) + "\n" + " func3(A self, short arg2, Tuple hello) -> int\n" + "\n" + " Parameters:\n" + " arg2: short\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" -" 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" -"" -) + "\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" -" 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" -"" -) + "\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" -" func2default(self, 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(self, e, arg3, hello) -> int\n" -"\n" -" Parameters:\n" -" e: A *\n" -" arg3: short\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" -"" -) + "\n" + " func2default(self, 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(self, e, arg3, hello) -> int\n" + "\n" + " Parameters:\n" + " e: A *\n" + " arg3: short\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" -" func3default(A self, 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 self, A e, short arg3, Tuple hello) -> int\n" -"\n" -" Parameters:\n" -" e: A *\n" -" arg3: short\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" -"" -) + "\n" + " func3default(A self, 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 self, A e, short arg3, Tuple hello) -> int\n" + "\n" + " Parameters:\n" + " e: A *\n" + " arg3: short\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" -" 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" -"" -) + "\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" -" 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" -"" -) + "\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" -" 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" -" " -, -"\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" -"" -) + "\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" + " ", + "\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" -" 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" -" " -, -"\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" -"" -) + "\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" + " ", + "\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", - "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" - "A_variable_d_get(A self) -> int\n" - "\n" - "Parameters:\n" - " self: A *\n" - "\n" - , - "A.variable_d" - ) + # Python 2.4 does not seem to work + 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" + "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", -"::B" -) + "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(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" -" a: special comment for parameter a\n" -" b: another special comment for parameter b\n" -" h: enum Hola\n" -"\n" -" " -, None, skip -) + "\n" + " __init__(self, a, b, h) -> E\n" + "\n" + " Parameters:\n" + " a: special comment for parameter a\n" + " b: another special comment for parameter b\n" + " h: enum Hola\n" + "\n" + " ", None, skip + ) check(F.__init__.__doc__, -"\n" -" __init__(F self, int a, int b, Hola h) -> F\n" -"\n" -" Parameters:\n" -" a: special comment for parameter a\n" -" b: another special comment for parameter b\n" -" h: enum Hola\n" -"\n" -" " -, None, skip -) + "\n" + " __init__(F self, int a, int b, Hola h) -> F\n" + "\n" + " Parameters:\n" + " a: special comment for parameter a\n" + " b: another special comment for parameter b\n" + " h: enum Hola\n" + "\n" + " ", None, skip + ) check(B.funk.__doc__, -"funk(B self, int c, int d) -> int", -"funk(int c, int d) -> int") + "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" -" 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" -"" -) + "\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") check(func_output.__doc__, "func_output() -> int") diff --git a/Examples/test-suite/python/callback_runme.py b/Examples/test-suite/python/callback_runme.py index b2bbb2d0f..ef7baad4e 100644 --- a/Examples/test-suite/python/callback_runme.py +++ b/Examples/test-suite/python/callback_runme.py @@ -2,30 +2,30 @@ import _callback from callback import * if foo(2) != 2: - raise RuntimeError + raise RuntimeError if A_bar(2) != 4: - raise RuntimeError + raise RuntimeError if foobar(3, _callback.foo) != foo(3): - raise RuntimeError + raise RuntimeError if foobar(3, foo) != foo(3): - raise RuntimeError + raise RuntimeError if foobar(3, A_bar) != A_bar(3): - raise RuntimeError + raise RuntimeError if foobar(3, foof) != foof(3): - raise RuntimeError + raise RuntimeError if foobar_i(3, foo_i) != foo_i(3): - raise RuntimeError + raise RuntimeError if foobar_d(3.5, foo_d) != foo_d(3.5): - raise RuntimeError + raise RuntimeError a = A() if foobarm(3, a, A.foom_cb_ptr) != a.foom(3): - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/char_binary_runme.py b/Examples/test-suite/python/char_binary_runme.py index b6d9c81c8..13457253f 100644 --- a/Examples/test-suite/python/char_binary_runme.py +++ b/Examples/test-suite/python/char_binary_runme.py @@ -2,11 +2,11 @@ from char_binary import * t = Test() if t.strlen('hile') != 4: - print t.strlen('hile') - raise RuntimeError, "bad multi-arg typemap" + print t.strlen('hile') + raise RuntimeError, "bad multi-arg typemap" if t.strlen('hil\0') != 4: - raise RuntimeError, "bad multi-arg typemap" + raise RuntimeError, "bad multi-arg typemap" # # creating a raw char* @@ -20,17 +20,16 @@ pchar_setitem(pc, 4, 0) if t.strlen(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" + print cvar.var_pchar + raise RuntimeError, "bad pointer case" cvar.var_namet = pc -#if cvar.var_namet != "hola\0": +# if cvar.var_namet != "hola\0": if cvar.var_namet != "hola": - raise RuntimeError, "bad pointer case" + raise RuntimeError, "bad pointer case" delete_pchar(pc) - diff --git a/Examples/test-suite/python/compactdefaultargs_runme.py b/Examples/test-suite/python/compactdefaultargs_runme.py index ff865714c..e81c8d173 100644 --- a/Examples/test-suite/python/compactdefaultargs_runme.py +++ b/Examples/test-suite/python/compactdefaultargs_runme.py @@ -4,17 +4,16 @@ defaults1 = Defaults1(1000) defaults1 = Defaults1() if defaults1.ret(10.0) != 10.0: - raise RuntimeError + raise RuntimeError if defaults1.ret() != -1.0: - raise RuntimeError + raise RuntimeError defaults2 = Defaults2(1000) defaults2 = Defaults2() if defaults2.ret(10.0) != 10.0: - raise RuntimeError + raise RuntimeError if defaults2.ret() != -1.0: - raise RuntimeError - + raise RuntimeError diff --git a/Examples/test-suite/python/complextest_runme.py b/Examples/test-suite/python/complextest_runme.py index cc2463a39..7dd7f5a3b 100644 --- a/Examples/test-suite/python/complextest_runme.py +++ b/Examples/test-suite/python/complextest_runme.py @@ -1,17 +1,17 @@ import complextest -a = complex(-1,2) +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" -v = (complex(1,2), complex(2,3), complex(4,3), 1) +v = (complex(1, 2), complex(2, 3), complex(4, 3), 1) try: - complextest.Copy_h(v) + complextest.Copy_h(v) except: - pass + pass diff --git a/Examples/test-suite/python/constant_directive_runme.py b/Examples/test-suite/python/constant_directive_runme.py index 48f85ce8a..a7ed82b8b 100644 --- a/Examples/test-suite/python/constant_directive_runme.py +++ b/Examples/test-suite/python/constant_directive_runme.py @@ -1,15 +1,20 @@ import constant_directive -if not isinstance(constant_directive.TYPE1_CONSTANT1,constant_directive.Type1): - raise RuntimeError("Failure: TYPE1_CONSTANT1 type: {}".format(type(constant_directive.TYPE1_CONSTANT1))) -if not isinstance(constant_directive.getType1Instance(),constant_directive.Type1): - raise RuntimeError("Failure: getType1Instance() type: {}".format(type(constant_directive.getType1Instance()))) +if not isinstance(constant_directive.TYPE1_CONSTANT1, constant_directive.Type1): + raise RuntimeError("Failure: TYPE1_CONSTANT1 type: {}".format( + type(constant_directive.TYPE1_CONSTANT1))) +if not isinstance(constant_directive.getType1Instance(), constant_directive.Type1): + raise RuntimeError("Failure: getType1Instance() type: {}".format( + type(constant_directive.getType1Instance()))) if constant_directive.TYPE1_CONSTANT1.val != 1: - raise RuntimeError("constant_directive.TYPE1_CONSTANT1.val is %r (should be 1)" % constant_directive.TYPE1_CONSTANT1.val) + raise RuntimeError("constant_directive.TYPE1_CONSTANT1.val is %r (should be 1)" % + constant_directive.TYPE1_CONSTANT1.val) if constant_directive.TYPE1_CONSTANT2.val != 2: - raise RuntimeError("constant_directive.TYPE1_CONSTANT2.val is %r (should be 2)" % constant_directive.TYPE1_CONSTANT2.val) + raise RuntimeError("constant_directive.TYPE1_CONSTANT2.val is %r (should be 2)" % + constant_directive.TYPE1_CONSTANT2.val) if constant_directive.TYPE1_CONSTANT3.val != 3: - raise RuntimeError("constant_directive.TYPE1_CONSTANT3.val is %r (should be 3)" % constant_directive.TYPE1_CONSTANT3.val) + raise RuntimeError("constant_directive.TYPE1_CONSTANT3.val is %r (should be 3)" % + constant_directive.TYPE1_CONSTANT3.val) diff --git a/Examples/test-suite/python/constover_runme.py b/Examples/test-suite/python/constover_runme.py index 5c5419706..2d28a55cc 100644 --- a/Examples/test-suite/python/constover_runme.py +++ b/Examples/test-suite/python/constover_runme.py @@ -11,7 +11,7 @@ p = constover.test_pconst("test") if p != "test_pconst": print "test_pconst failed!" error = 1 - + f = constover.Foo() p = f.test("test") if p != "test": @@ -32,7 +32,5 @@ p = f.test_pconstm("test") if p != "test_pconstmethod": print "member-test_pconstm failed!" error = 1 - + sys.exit(error) - - diff --git a/Examples/test-suite/python/constructor_copy_runme.py b/Examples/test-suite/python/constructor_copy_runme.py index 431d3232f..a54bc106f 100644 --- a/Examples/test-suite/python/constructor_copy_runme.py +++ b/Examples/test-suite/python/constructor_copy_runme.py @@ -1,7 +1,7 @@ from constructor_copy import * -f1 = Foo1(3); -f11 = Foo1(f1); +f1 = Foo1(3) +f11 = Foo1(f1) if f1.x != f11.x: @@ -24,7 +24,7 @@ bc = Bari(bi) if (bi.x != bc.x): raise RuntimeError - + bd = Bard(5) try: @@ -35,4 +35,3 @@ except: if not good: raise RuntimeError - diff --git a/Examples/test-suite/python/contract_runme.py b/Examples/test-suite/python/contract_runme.py index 905bf1196..cd75a51d2 100644 --- a/Examples/test-suite/python/contract_runme.py +++ b/Examples/test-suite/python/contract_runme.py @@ -1,143 +1,142 @@ import contract -contract.test_preassert(1,2) +contract.test_preassert(1, 2) try: - contract.test_preassert(-1) - print "Failed! Preassertions are broken" + contract.test_preassert(-1) + print "Failed! Preassertions are broken" except: - pass + pass contract.test_postassert(3) try: - contract.test_postassert(-3) - print "Failed! Postassertions are broken" + contract.test_postassert(-3) + print "Failed! Postassertions are broken" except: - pass + pass -contract.test_prepost(2,3) -contract.test_prepost(5,-4) +contract.test_prepost(2, 3) +contract.test_prepost(5, -4) try: - contract.test_prepost(-3,4) - print "Failed! Preassertions are broken" + contract.test_prepost(-3, 4) + print "Failed! Preassertions are broken" except: - pass + pass try: - contract.test_prepost(4,-10) - print "Failed! Postassertions are broken" + contract.test_prepost(4, -10) + print "Failed! Postassertions are broken" except: - pass + pass f = contract.Foo() -f.test_preassert(4,5) +f.test_preassert(4, 5) try: - f.test_preassert(-2,3) - print "Failed! Method preassertion." + f.test_preassert(-2, 3) + print "Failed! Method preassertion." except: - pass + pass f.test_postassert(4) try: - f.test_postassert(-4) - print "Failed! Method postassertion" + f.test_postassert(-4) + print "Failed! Method postassertion" except: - pass + pass -f.test_prepost(3,4) -f.test_prepost(4,-3) +f.test_prepost(3, 4) +f.test_prepost(4, -3) try: - f.test_prepost(-4,2) - print "Failed! Method preassertion." + f.test_prepost(-4, 2) + print "Failed! Method preassertion." except: - pass + pass try: - f.test_prepost(4,-10) - print "Failed! Method postassertion." + f.test_prepost(4, -10) + print "Failed! Method postassertion." except: - pass + pass -contract.Foo_stest_prepost(4,0) +contract.Foo_stest_prepost(4, 0) try: - contract.Foo_stest_prepost(-4,2) - print "Failed! Static method preassertion" + contract.Foo_stest_prepost(-4, 2) + print "Failed! Static method preassertion" except: - pass + pass try: - contract.Foo_stest_prepost(4,-10) - print "Failed! Static method posteassertion" + contract.Foo_stest_prepost(4, -10) + print "Failed! Static method posteassertion" except: - pass - + pass + b = contract.Bar() try: - b.test_prepost(2,-4) - print "Failed! Inherited preassertion." + b.test_prepost(2, -4) + print "Failed! Inherited preassertion." except: - pass + pass d = contract.D() try: - d.foo(-1,1,1,1,1) - print "Failed! Inherited preassertion (D)." + d.foo(-1, 1, 1, 1, 1) + print "Failed! Inherited preassertion (D)." except: - pass + pass try: - d.foo(1,-1,1,1,1) - print "Failed! Inherited preassertion (D)." + d.foo(1, -1, 1, 1, 1) + print "Failed! Inherited preassertion (D)." except: - pass + pass try: - d.foo(1,1,-1,1,1) - print "Failed! Inherited preassertion (D)." + d.foo(1, 1, -1, 1, 1) + print "Failed! Inherited preassertion (D)." except: - pass + pass try: - d.foo(1,1,1,-1,1) - print "Failed! Inherited preassertion (D)." + d.foo(1, 1, 1, -1, 1) + print "Failed! Inherited preassertion (D)." except: - pass + pass try: - d.foo(1,1,1,1,-1) - print "Failed! Inherited preassertion (D)." + d.foo(1, 1, 1, 1, -1) + print "Failed! Inherited preassertion (D)." except: - pass + pass try: - d.bar(-1,1,1,1,1) - print "Failed! Inherited preassertion (D)." + d.bar(-1, 1, 1, 1, 1) + print "Failed! Inherited preassertion (D)." except: - pass + pass try: - d.bar(1,-1,1,1,1) - print "Failed! Inherited preassertion (D)." + d.bar(1, -1, 1, 1, 1) + print "Failed! Inherited preassertion (D)." except: - pass + pass try: - d.bar(1,1,-1,1,1) - print "Failed! Inherited preassertion (D)." + d.bar(1, 1, -1, 1, 1) + print "Failed! Inherited preassertion (D)." except: - pass + pass try: - d.bar(1,1,1,-1,1) - print "Failed! Inherited preassertion (D)." + d.bar(1, 1, 1, -1, 1) + print "Failed! Inherited preassertion (D)." except: - pass + pass try: - d.bar(1,1,1,1,-1) - print "Failed! Inherited preassertion (D)." + d.bar(1, 1, 1, 1, -1) + print "Failed! Inherited preassertion (D)." except: - pass + pass -#Namespace +# Namespace my = contract.myClass(1) try: - my = contract.myClass(0) - print "Failed! constructor preassertion" + my = contract.myClass(0) + print "Failed! constructor preassertion" except: - pass - + pass diff --git a/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py b/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py index 0a1c45716..363736a84 100644 --- a/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py +++ b/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py @@ -2,12 +2,13 @@ import cpp11_alternate_function_syntax a = cpp11_alternate_function_syntax.SomeStruct() -res = a.addNormal(4,5) +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) +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.") diff --git a/Examples/test-suite/python/cpp11_decltype_runme.py b/Examples/test-suite/python/cpp11_decltype_runme.py index bfcbbec79..1650d9004 100644 --- a/Examples/test-suite/python/cpp11_decltype_runme.py +++ b/Examples/test-suite/python/cpp11_decltype_runme.py @@ -3,17 +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." diff --git a/Examples/test-suite/python/cpp11_function_objects_runme.py b/Examples/test-suite/python/cpp11_function_objects_runme.py index 5a63b632b..d1515c16c 100644 --- a/Examples/test-suite/python/cpp11_function_objects_runme.py +++ b/Examples/test-suite/python/cpp11_function_objects_runme.py @@ -1,7 +1,9 @@ import cpp11_function_objects import sys + class Test1(cpp11_function_objects.Test): + def __init__(self): cpp11_function_objects.Test.__init__(self) @@ -10,14 +12,17 @@ class Test1(cpp11_function_objects.Test): 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)) + raise RuntimeError( + "Runtime cpp11_function_objects failed. t.value should be 0, but is " + str(t.value)) -t(1,2) # adds numbers and sets value +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)) - + 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) +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)) + 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_initializer_list_extend_runme.py b/Examples/test-suite/python/cpp11_initializer_list_extend_runme.py index eedf8f148..285273efa 100644 --- a/Examples/test-suite/python/cpp11_initializer_list_extend_runme.py +++ b/Examples/test-suite/python/cpp11_initializer_list_extend_runme.py @@ -1,4 +1,3 @@ import cpp11_initializer_list_extend -c = cpp11_initializer_list_extend.Container( [10, 20, 30, 40] ) - +c = cpp11_initializer_list_extend.Container([10, 20, 30, 40]) diff --git a/Examples/test-suite/python/cpp11_initializer_list_runme.py b/Examples/test-suite/python/cpp11_initializer_list_runme.py index 395cd610d..84f955f63 100644 --- a/Examples/test-suite/python/cpp11_initializer_list_runme.py +++ b/Examples/test-suite/python/cpp11_initializer_list_runme.py @@ -2,4 +2,3 @@ import cpp11_initializer_list a = cpp11_initializer_list.A() a = cpp11_initializer_list.A(11.1) - diff --git a/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py b/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py index d304c139d..54a8fe0eb 100644 --- a/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py +++ b/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py @@ -3,13 +3,15 @@ import cpp11_null_pointer_constant a = cpp11_null_pointer_constant.A() if a._myA != None: - raise RuntimeError, ("cpp11_null_pointer_constant: _myA should be None, but is ", a._myA) + 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, ("cpp11_null_pointer_constant: a._myA should be the same as b._myA, but ", a._myA, "!=", b._myA) + 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") diff --git a/Examples/test-suite/python/cpp11_raw_string_literals_runme.py b/Examples/test-suite/python/cpp11_raw_string_literals_runme.py index 32282d8d8..29e53c6a7 100644 --- a/Examples/test-suite/python/cpp11_raw_string_literals_runme.py +++ b/Examples/test-suite/python/cpp11_raw_string_literals_runme.py @@ -1,50 +1,48 @@ from cpp11_raw_string_literals import * if cvar.L != 100: - raise RuntimeError + raise RuntimeError if cvar.u8 != 100: - raise RuntimeError + raise RuntimeError if cvar.u != 100: - raise RuntimeError + raise RuntimeError if UStruct.U != 100: - raise RuntimeError + raise RuntimeError if cvar.R != 100: - raise RuntimeError + raise RuntimeError if cvar.LR != 100: - raise RuntimeError + raise RuntimeError if cvar.u8R != 100: - raise RuntimeError + raise RuntimeError if cvar.uR != 100: - raise RuntimeError + raise RuntimeError if URStruct.UR != 100: - raise RuntimeError + raise RuntimeError if cvar.aa != "Wide string": - raise RuntimeError + 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 diff --git a/Examples/test-suite/python/cpp11_result_of_runme.py b/Examples/test-suite/python/cpp11_result_of_runme.py index 4dc39fcdf..4469efd81 100644 --- a/Examples/test-suite/python/cpp11_result_of_runme.py +++ b/Examples/test-suite/python/cpp11_result_of_runme.py @@ -2,8 +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) diff --git a/Examples/test-suite/python/cpp11_rvalue_reference_runme.py b/Examples/test-suite/python/cpp11_rvalue_reference_runme.py index a72a3e63b..c1cd3bf26 100644 --- a/Examples/test-suite/python/cpp11_rvalue_reference_runme.py +++ b/Examples/test-suite/python/cpp11_rvalue_reference_runme.py @@ -4,21 +4,24 @@ a = cpp11_rvalue_reference.A() a.setAcopy(5) if a.getAcopy() != 5: - raise RunTimeError, ("int A::getAcopy() value is ", a.getAcopy(), " should be 5") + 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(), " should be 5") + 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(), " should be 5") + 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(), " should be 5") - + raise RunTimeError, ("after A::setAmove(): int A::getAcopy() value is ", a.getAcopy( + ), " should be 5") diff --git a/Examples/test-suite/python/cpp11_strongly_typed_enumerations_runme.py b/Examples/test-suite/python/cpp11_strongly_typed_enumerations_runme.py index 6509ba873..21b4f63f5 100644 --- a/Examples/test-suite/python/cpp11_strongly_typed_enumerations_runme.py +++ b/Examples/test-suite/python/cpp11_strongly_typed_enumerations_runme.py @@ -1,9 +1,11 @@ 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 + if actual != expected: + raise RuntimeError( + "Enum value mismatch. Expected " + str(expected) + " Actual: " + str(actual)) + return expected + 1 val = 0 val = enumCheck(Enum1_Val1, val) @@ -161,4 +163,3 @@ enumCheck(class1.class1Test2(Class1.Enum12_Val5c), 1121) 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/cpp11_thread_local_runme.py b/Examples/test-suite/python/cpp11_thread_local_runme.py index 59a657488..83f2390ec 100644 --- a/Examples/test-suite/python/cpp11_thread_local_runme.py +++ b/Examples/test-suite/python/cpp11_thread_local_runme.py @@ -2,37 +2,36 @@ from cpp11_thread_local import * t = ThreadLocals() if t.stval != 11: - raise RuntimeError + raise RuntimeError if t.tsval != 22: - raise RuntimeError + raise RuntimeError if t.tscval99 != 99: - raise RuntimeError + raise RuntimeError cvar.etval = -11 if cvar.etval != -11: - raise RuntimeError + raise RuntimeError cvar.stval = -22 if cvar.stval != -22: - raise RuntimeError + raise RuntimeError cvar.tsval = -33 if cvar.tsval != -33: - raise RuntimeError + raise RuntimeError cvar.etval = -44 if cvar.etval != -44: - raise RuntimeError + raise RuntimeError cvar.teval = -55 if cvar.teval != -55: - raise RuntimeError + raise RuntimeError cvar.ectval = -66 if cvar.ectval != -66: - raise RuntimeError + raise RuntimeError cvar.ecpptval = -66 if cvar.ecpptval != -66: - raise RuntimeError - + raise RuntimeError diff --git a/Examples/test-suite/python/cpp11_type_traits_runme.py b/Examples/test-suite/python/cpp11_type_traits_runme.py index cb58656a6..d0dfb23d7 100644 --- a/Examples/test-suite/python/cpp11_type_traits_runme.py +++ b/Examples/test-suite/python/cpp11_type_traits_runme.py @@ -1,7 +1,7 @@ from cpp11_type_traits import * if Elaborate(0, 0) != 1: - raise RuntimeError("Elaborate should have returned 1") + raise RuntimeError("Elaborate should have returned 1") if Elaborate(0, 0.0) != 2: - raise RuntimeError("Elaborate should have returned 2") + raise RuntimeError("Elaborate should have returned 2") diff --git a/Examples/test-suite/python/cpp11_uniform_initialization_runme.py b/Examples/test-suite/python/cpp11_uniform_initialization_runme.py index 85c3b2478..ecb468ccb 100644 --- a/Examples/test-suite/python/cpp11_uniform_initialization_runme.py +++ b/Examples/test-suite/python/cpp11_uniform_initialization_runme.py @@ -2,20 +2,20 @@ import cpp11_uniform_initialization var1 = cpp11_uniform_initialization.cvar.var1 if var1.x != 5: - raise RuntimeError + raise RuntimeError var2 = cpp11_uniform_initialization.cvar.var2 if var2.getX() != 2: - raise RuntimeError + raise RuntimeError 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 -if m.more1( [-1,1,2] ) != 2: - raise RuntimeError, m.vi + raise RuntimeError, m.vi +if m.more1([-1, 1, 2]) != 2: + raise RuntimeError, m.vi if m.more1() != 10: - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/cpp_enum_runme.py b/Examples/test-suite/python/cpp_enum_runme.py index 0054ae281..5f1e91c97 100644 --- a/Examples/test-suite/python/cpp_enum_runme.py +++ b/Examples/test-suite/python/cpp_enum_runme.py @@ -3,21 +3,21 @@ import cpp_enum f = cpp_enum.Foo() if f.hola != f.Hello: - print f.hola - raise RuntimeError + print f.hola + raise RuntimeError f.hola = f.Hi if f.hola != f.Hi: - print f.hola - raise RuntimeError + print f.hola + raise RuntimeError f.hola = f.Hello if f.hola != f.Hello: - print f.hola - raise RuntimeError + print f.hola + raise RuntimeError cpp_enum.cvar.hi = cpp_enum.Hello if cpp_enum.cvar.hi != cpp_enum.Hello: - print cpp_enum.cvar.hi - raise RuntimeError + print cpp_enum.cvar.hi + raise RuntimeError diff --git a/Examples/test-suite/python/cpp_namespace_runme.py b/Examples/test-suite/python/cpp_namespace_runme.py index a454774f5..2ab959aea 100644 --- a/Examples/test-suite/python/cpp_namespace_runme.py +++ b/Examples/test-suite/python/cpp_namespace_runme.py @@ -17,7 +17,7 @@ if cpp_namespace.do_method(t) != "Test::method": if cpp_namespace.do_method2(t) != "Test::method": raise RuntimeError("Bad return value!") - + cpp_namespace.weird("hello", 4) del t @@ -30,16 +30,14 @@ t5 = cpp_namespace.Test5() if cpp_namespace.foo3(42) != 42: raise RuntimeError("Bad return value!") -if cpp_namespace.do_method3(t2,40) != "Test2::method": +if cpp_namespace.do_method3(t2, 40) != "Test2::method": raise RuntimeError("Bad return value!") -if cpp_namespace.do_method3(t3,40) != "Test3::method": +if cpp_namespace.do_method3(t3, 40) != "Test3::method": raise RuntimeError("Bad return value!") -if cpp_namespace.do_method3(t4,40) != "Test4::method": +if cpp_namespace.do_method3(t4, 40) != "Test4::method": raise RuntimeError("Bad return value!") -if cpp_namespace.do_method3(t5,40) != "Test5::method": +if cpp_namespace.do_method3(t5, 40) != "Test5::method": raise RuntimeError("Bad return value!") - - diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py index eef921780..b742de285 100644 --- a/Examples/test-suite/python/cpp_static_runme.py +++ b/Examples/test-suite/python/cpp_static_runme.py @@ -1,16 +1,17 @@ #!/usr/bin/evn python from cpp_static import * + def is_new_style_class(cls): - return hasattr(cls, "__class__") + return hasattr(cls, "__class__") if is_new_style_class(StaticFunctionTest): - StaticFunctionTest.static_func() - StaticFunctionTest.static_func_2(1) - StaticFunctionTest.static_func_3(1,2) + StaticFunctionTest.static_func() + StaticFunctionTest.static_func_2(1) + StaticFunctionTest.static_func_3(1, 2) else: - StaticFunctionTest().static_func() - StaticFunctionTest().static_func_2(1) - StaticFunctionTest().static_func_3(1,2) + StaticFunctionTest().static_func() + StaticFunctionTest().static_func_2(1) + StaticFunctionTest().static_func_3(1, 2) StaticMemberTest.static_int = 10 assert StaticMemberTest.static_int == 10 diff --git a/Examples/test-suite/python/default_arg_values_runme.py b/Examples/test-suite/python/default_arg_values_runme.py index 28145b256..7ed52a65b 100644 --- a/Examples/test-suite/python/default_arg_values_runme.py +++ b/Examples/test-suite/python/default_arg_values_runme.py @@ -3,17 +3,17 @@ from default_arg_values import * d = Display() if d.draw1() != 0: - raise RuntimeError + raise RuntimeError if d.draw1(12) != 12: - raise RuntimeError + raise RuntimeError -p = createPtr(123); +p = createPtr(123) if d.draw2() != 0: - raise RuntimeError + raise RuntimeError if d.draw2(p) != 123: - raise RuntimeError + raise RuntimeError if d.bool0() != False or type(d.bool0()) != type(False): raise RuntimeError diff --git a/Examples/test-suite/python/default_args_runme.py b/Examples/test-suite/python/default_args_runme.py index 0931bfd3d..11878f7a4 100644 --- a/Examples/test-suite/python/default_args_runme.py +++ b/Examples/test-suite/python/default_args_runme.py @@ -1,122 +1,133 @@ -# Note that this test is also used by python_default_args_runme.py hence the use of __main__ and the run function +# Note that this test is also used by python_default_args_runme.py hence +# the use of __main__ and the run function + def is_new_style_class(cls): - return hasattr(cls, "__class__") + return hasattr(cls, "__class__") + 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") + 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) + de = default_args.DerivedEnumClass() + de.accelerate() + de.accelerate(default_args.EnumClass.SLOW) - if default_args.Statics_staticMethod() != 60: - raise RuntimeError + if default_args.Statics_staticMethod() != 60: + raise RuntimeError - if default_args.cfunc1(1) != 2: - raise RuntimeError + if default_args.cfunc1(1) != 2: + raise RuntimeError - if default_args.cfunc2(1) != 3: - raise RuntimeError + if default_args.cfunc2(1) != 3: + raise RuntimeError - if default_args.cfunc3(1) != 4: - raise RuntimeError + if default_args.cfunc3(1) != 4: + raise RuntimeError + + f = default_args.Foo() + + f.newname() + f.newname(1) + + if f.double_if_void_ptr_is_null(2, None) != 4: + raise RuntimeError + + if f.double_if_void_ptr_is_null(3) != 6: + raise RuntimeError + + if f.double_if_handle_is_null(4, None) != 8: + raise RuntimeError + + if f.double_if_handle_is_null(5) != 10: + raise RuntimeError + + if f.double_if_dbl_ptr_is_null(6, None) != 12: + raise RuntimeError + + if f.double_if_dbl_ptr_is_null(7) != 14: + raise RuntimeError + + 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 is_new_style_class(default_args.Klass): + Klass_inc = default_args.Klass.inc + else: + Klass_inc = default_args.Klass_inc + + if Klass_inc(100, default_args.Klass(22)).val != 122: + raise RuntimeError("Klass::inc failed") + + if Klass_inc(100).val != 99: + raise RuntimeError("Klass::inc failed") + + if 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 default_args.slightly_off_square(10) != 102: + raise RuntimeError + + if default_args.slightly_off_square() != 291: + raise RuntimeError - f = default_args.Foo() - - f.newname() - f.newname(1) - - if f.double_if_void_ptr_is_null(2, None) != 4: - raise RuntimeError - - if f.double_if_void_ptr_is_null(3) != 6: - raise RuntimeError - - if f.double_if_handle_is_null(4, None) != 8: - raise RuntimeError - - if f.double_if_handle_is_null(5) != 10: - raise RuntimeError - - if f.double_if_dbl_ptr_is_null(6, None) != 12: - raise RuntimeError - - if f.double_if_dbl_ptr_is_null(7) != 14: - raise RuntimeError - - 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 is_new_style_class(default_args.Klass): - Klass_inc = default_args.Klass.inc - else: - Klass_inc = default_args.Klass_inc - - if Klass_inc(100, default_args.Klass(22)).val != 122: - raise RuntimeError("Klass::inc failed") - - if Klass_inc(100).val != 99: - raise RuntimeError("Klass::inc failed") - - if 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 default_args.slightly_off_square(10) != 102: - raise RuntimeError - - if default_args.slightly_off_square() != 291: - raise RuntimeError - - -if __name__=="__main__": - run('default_args') - +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 e6532031b..c80c1e81e 100644 --- a/Examples/test-suite/python/default_constructor_runme.py +++ b/Examples/test-suite/python/default_constructor_runme.py @@ -4,7 +4,7 @@ import _default_constructor # It uses the old static syntax (e.g., dc.new_A() rather than dc.A()), # which is not provided with the -builtin option. if _default_constructor.is_python_builtin(): - exit(0) + exit(0) dc = _default_constructor @@ -23,7 +23,7 @@ except: del_b = dc.delete_B try: - bb = dc.new_BB(); + bb = dc.new_BB() print "Whoa. new_BB created." except: pass @@ -42,7 +42,7 @@ cc = dc.new_CC() dc.delete_CC(cc) try: - d = dc.new_D(); + d = dc.new_D() print "Whoa. new_D created" except: pass @@ -113,5 +113,4 @@ dc.delete_GG(gg) import default_constructor -hh = default_constructor.HH(1,1) - +hh = default_constructor.HH(1, 1) diff --git a/Examples/test-suite/python/director_abstract_runme.py b/Examples/test-suite/python/director_abstract_runme.py index 886cda0ae..031c476d8 100644 --- a/Examples/test-suite/python/director_abstract_runme.py +++ b/Examples/test-suite/python/director_abstract_runme.py @@ -1,79 +1,91 @@ import director_abstract + def is_new_style_class(cls): - return hasattr(cls, "__class__") + return hasattr(cls, "__class__") + class MyFoo(director_abstract.Foo): - def __init__(self): - director_abstract.Foo.__init__(self) - def ping(self): - return "MyFoo::ping()" + + def __init__(self): + director_abstract.Foo.__init__(self) + + def ping(self): + return "MyFoo::ping()" 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): - def Color(self, r, g, b): - return r + + def Color(self, r, g, b): + return r + class MyExample2(director_abstract.Example2): - def Color(self, r, g, b): - return g + + def Color(self, r, g, b): + return g + class MyExample3(director_abstract.Example3_i): - def Color(self, r, g, b): - return b + + def Color(self, r, g, b): + return b me1 = MyExample1() -if director_abstract.Example1_get_color(me1, 1,2,3) != 1: - raise RuntimeError +if director_abstract.Example1_get_color(me1, 1, 2, 3) != 1: + raise RuntimeError if is_new_style_class(MyExample2): - MyExample2_static = MyExample2 + MyExample2_static = MyExample2 else: - MyExample2_static = MyExample2(0, 0) -me2 = MyExample2(1,2) -if MyExample2_static.get_color(me2, 1,2,3) != 2: - raise RuntimeError + MyExample2_static = MyExample2(0, 0) +me2 = MyExample2(1, 2) +if MyExample2_static.get_color(me2, 1, 2, 3) != 2: + raise RuntimeError if is_new_style_class(MyExample3): - MyExample3_static = MyExample3 + MyExample3_static = MyExample3 else: - MyExample3_static = MyExample3() + MyExample3_static = MyExample3() me3 = MyExample3() -if MyExample3_static.get_color(me3, 1,2,3) != 3: - raise RuntimeError +if MyExample3_static.get_color(me3, 1, 2, 3) != 3: + raise RuntimeError error = 1 try: - me1 = director_abstract.Example1() + me1 = director_abstract.Example1() except: - error = 0 -if (error): raise RuntimeError + error = 0 +if (error): + raise RuntimeError error = 1 try: - me2 = director_abstract.Example2() + me2 = director_abstract.Example2() except: - error = 0 -if (error): raise RuntimeError + error = 0 +if (error): + raise RuntimeError error = 1 try: - me3 = director_abstract.Example3_i() + me3 = director_abstract.Example3_i() except: - error = 0 -if (error): raise RuntimeError + error = 0 +if (error): + raise RuntimeError try: - f = director_abstract.A.f + f = director_abstract.A.f except: - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/director_alternating_runme.py b/Examples/test-suite/python/director_alternating_runme.py index a92ae1c5c..a93ffec34 100644 --- a/Examples/test-suite/python/director_alternating_runme.py +++ b/Examples/test-suite/python/director_alternating_runme.py @@ -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) diff --git a/Examples/test-suite/python/director_basic_runme.py b/Examples/test-suite/python/director_basic_runme.py index 541139814..6564c95a2 100644 --- a/Examples/test-suite/python/director_basic_runme.py +++ b/Examples/test-suite/python/director_basic_runme.py @@ -1,41 +1,43 @@ import director_basic + class PyFoo(director_basic.Foo): - def ping(self): - return "PyFoo::ping()" + + def ping(self): + return "PyFoo::ping()" 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) if a.rg(2) != 2: - raise RuntimeError - + raise RuntimeError class PyClass(director_basic.MyClass): - def method(self, vptr): - self.cmethod = 7 - pass - - def vmethod(self, b): - b.x = b.x + 31 - return b + + def method(self, vptr): + self.cmethod = 7 + pass + + def vmethod(self, b): + b.x = b.x + 31 + return b b = director_basic.Bar(3) @@ -50,49 +52,42 @@ bd = dd.cmethod(b) cc.method(b) if c.cmethod != 7: - raise RuntimeError + raise RuntimeError if bc.x != 34: - raise RuntimeError + raise RuntimeError if bd.x != 16: - raise RuntimeError - + raise RuntimeError class PyMulti(director_basic.Foo, director_basic.MyClass): - def __init__(self): - director_basic.Foo.__init__(self) - director_basic.MyClass.__init__(self) - pass - - def vmethod(self, b): - b.x = b.x + 31 - return b + def __init__(self): + director_basic.Foo.__init__(self) + director_basic.MyClass.__init__(self) + pass - - def ping(self): - return "PyFoo::ping()" + def vmethod(self, b): + b.x = b.x + 31 + return b + + def ping(self): + return "PyFoo::ping()" a = 0 -for i in range(0,100): +for i in range(0, 100): pymult = PyMulti() pymult.pong() - del pymult - + del pymult pymult = PyMulti() - - p1 = director_basic.Foo_get_self(pymult) p2 = director_basic.MyClass_get_self(pymult) p1.ping() p2.vmethod(bc) - - diff --git a/Examples/test-suite/python/director_classic_runme.py b/Examples/test-suite/python/director_classic_runme.py index 7e18a9a61..9dd5f5967 100644 --- a/Examples/test-suite/python/director_classic_runme.py +++ b/Examples/test-suite/python/director_classic_runme.py @@ -1,53 +1,76 @@ from director_classic import * + class TargetLangPerson(Person): + def __init__(self): Person.__init__(self) + def id(self): identifier = "TargetLangPerson" return identifier + class TargetLangChild(Child): + def __init__(self): Child.__init__(self) + def id(self): identifier = "TargetLangChild" return identifier + class TargetLangGrandChild(GrandChild): + def __init__(self): GrandChild.__init__(self) + def id(self): identifier = "TargetLangGrandChild" return identifier # Semis - don't override id() in target language + + class TargetLangSemiPerson(Person): + def __init__(self): Person.__init__(self) # No id() override + class TargetLangSemiChild(Child): + def __init__(self): Child.__init__(self) # No id() override + class TargetLangSemiGrandChild(GrandChild): + def __init__(self): GrandChild.__init__(self) # No id() override # Orphans - don't override id() in C++ + + class TargetLangOrphanPerson(OrphanPerson): + def __init__(self): OrphanPerson.__init__(self) + def id(self): identifier = "TargetLangOrphanPerson" return identifier + class TargetLangOrphanChild(OrphanChild): + def __init__(self): Child.__init__(self) + def id(self): identifier = "TargetLangOrphanChild" return identifier @@ -55,88 +78,90 @@ class TargetLangOrphanChild(OrphanChild): def check(person, expected): - debug = 0 - # Normal target language polymorphic call - ret = person.id() - if (debug): - print(ret) - if (ret != expected): - raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected) + debug = 0 + # Normal target language polymorphic call + ret = person.id() + if (debug): + print(ret) + if (ret != expected): + raise RuntimeError( + "Failed. Received: " + str(ret) + " Expected: " + expected) - # Polymorphic call from C++ - caller = Caller() - caller.setCallback(person) - ret = caller.call() - if (debug): - print(ret) - if (ret != expected): - raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected) + # Polymorphic call from C++ + caller = Caller() + caller.setCallback(person) + ret = caller.call() + if (debug): + print(ret) + if (ret != expected): + raise RuntimeError( + "Failed. Received: " + str(ret) + " Expected: " + expected) - # Polymorphic call of object created in target language and passed to C++ and back again - baseclass = caller.baseClass() - ret = baseclass.id() - if (debug): - print(ret) - if (ret != expected): - raise RuntimeError("Failed. Received: " + str(ret)+ " Expected: " + expected) + # Polymorphic call of object created in target language and passed to C++ + # and back again + baseclass = caller.baseClass() + ret = baseclass.id() + if (debug): + print(ret) + if (ret != expected): + raise RuntimeError( + "Failed. Received: " + str(ret) + " Expected: " + expected) - caller.resetCallback() - if (debug): - print("----------------------------------------") + caller.resetCallback() + if (debug): + print("----------------------------------------") - -person = Person(); -check(person, "Person"); +person = Person() +check(person, "Person") del person -person = Child(); -check(person, "Child"); +person = Child() +check(person, "Child") del person -person = GrandChild(); -check(person, "GrandChild"); +person = GrandChild() +check(person, "GrandChild") del person -person = TargetLangPerson(); -check(person, "TargetLangPerson"); +person = TargetLangPerson() +check(person, "TargetLangPerson") del person -person = TargetLangChild(); -check(person, "TargetLangChild"); +person = TargetLangChild() +check(person, "TargetLangChild") del person -person = TargetLangGrandChild(); -check(person, "TargetLangGrandChild"); +person = TargetLangGrandChild() +check(person, "TargetLangGrandChild") del person # Semis - don't override id() in target language -person = TargetLangSemiPerson(); -check(person, "Person"); +person = TargetLangSemiPerson() +check(person, "Person") del person -person = TargetLangSemiChild(); -check(person, "Child"); +person = TargetLangSemiChild() +check(person, "Child") del person -person = TargetLangSemiGrandChild(); -check(person, "GrandChild"); +person = TargetLangSemiGrandChild() +check(person, "GrandChild") del person # Orphans - don't override id() in C++ -person = OrphanPerson(); -check(person, "Person"); +person = OrphanPerson() +check(person, "Person") del person -person = OrphanChild(); -check(person, "Child"); +person = OrphanChild() +check(person, "Child") del person -person = TargetLangOrphanPerson(); -check(person, "TargetLangOrphanPerson"); +person = TargetLangOrphanPerson() +check(person, "TargetLangOrphanPerson") del person -person = TargetLangOrphanChild(); -check(person, "TargetLangOrphanChild"); +person = TargetLangOrphanChild() +check(person, "TargetLangOrphanChild") del person - diff --git a/Examples/test-suite/python/director_detect_runme.py b/Examples/test-suite/python/director_detect_runme.py index a90cfe8b4..345051982 100644 --- a/Examples/test-suite/python/director_detect_runme.py +++ b/Examples/test-suite/python/director_detect_runme.py @@ -1,24 +1,26 @@ -import director_detect +import director_detect + class MyBar(director_detect.Bar): - def __init__(self, val = 2): - director_detect.Bar.__init__(self) - self.val = val - def get_value(self): - self.val = self.val + 1 - return self.val - - def get_class(self): - self.val = self.val + 1 - return director_detect.A() + def __init__(self, val=2): + director_detect.Bar.__init__(self) + self.val = val - def just_do_it(self): - self.val = self.val + 1 + def get_value(self): + self.val = self.val + 1 + return self.val - def clone(self): - return MyBar(self.val) - pass + def get_class(self): + self.val = self.val + 1 + return director_detect.A() + + def just_do_it(self): + self.val = self.val + 1 + + def clone(self): + return MyBar(self.val) + pass b = MyBar() @@ -33,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" diff --git a/Examples/test-suite/python/director_enum_runme.py b/Examples/test-suite/python/director_enum_runme.py index 5692c88b8..faa2d82df 100644 --- a/Examples/test-suite/python/director_enum_runme.py +++ b/Examples/test-suite/python/director_enum_runme.py @@ -1,12 +1,14 @@ import director_enum + class MyFoo(director_enum.Foo): - def say_hi(self, val): - return val + + def say_hi(self, val): + return val b = director_enum.Foo() a = MyFoo() if a.say_hi(director_enum.hello) != b.say_hello(director_enum.hi): - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py index de3ef22a5..892c7e653 100644 --- a/Examples/test-suite/python/director_exception_runme.py +++ b/Examples/test-suite/python/director_exception_runme.py @@ -1,21 +1,29 @@ from director_exception import * + class MyException(Exception): - def __init__(self, a, b): - self.msg = a + b + + def __init__(self, a, b): + self.msg = a + b + class MyFoo(Foo): - def ping(self): - raise NotImplementedError, "MyFoo::ping() EXCEPTION" + + def ping(self): + raise NotImplementedError, "MyFoo::ping() EXCEPTION" + class MyFoo2(Foo): - def ping(self): - return True - pass # error: should return a string + + def ping(self): + return True + pass # error: should return a string + class MyFoo3(Foo): - def ping(self): - raise MyException("foo", "bar") + + def ping(self): + raise MyException("foo", "bar") # Check that the NotImplementedError raised by MyFoo.ping() is returned by # MyFoo.pong(). @@ -23,16 +31,16 @@ ok = 0 a = MyFoo() b = launder(a) try: - b.pong() + b.pong() except NotImplementedError, e: - if str(e) == "MyFoo::ping() EXCEPTION": - ok = 1 - else: - print "Unexpected error message: %s" % str(e) + if str(e) == "MyFoo::ping() EXCEPTION": + ok = 1 + else: + print "Unexpected error message: %s" % str(e) except: - pass + pass if not ok: - raise RuntimeError + raise RuntimeError # Check that the director returns the appropriate TypeError if the return type @@ -41,14 +49,14 @@ ok = 0 a = MyFoo2() b = launder(a) try: - b.pong() + b.pong() except TypeError, e: - if str(e) == "SWIG director type mismatch in output value of type 'std::string'": - ok = 1 - else: - print "Unexpected error message: %s" % str(e) + if str(e) == "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 + raise RuntimeError # Check that the director can return an exception which requires two arguments @@ -57,24 +65,24 @@ ok = 0 a = MyFoo3() b = launder(a) try: - b.pong() + b.pong() except MyException, e: - if e.msg == 'foobar': - ok = 1 - else: - print "Unexpected error message: %s" % str(e) + if e.msg == 'foobar': + ok = 1 + else: + print "Unexpected error message: %s" % str(e) if not ok: - raise RuntimeError + raise RuntimeError # This is expected to fail with -builtin option # Throwing builtin classes as exceptions not supported if not is_python_builtin(): - try: - raise Exception2() - except Exception2: - pass + try: + raise Exception2() + except Exception2: + pass - try: - raise Exception1() - except Exception1: - pass + try: + raise Exception1() + except Exception1: + pass diff --git a/Examples/test-suite/python/director_extend_runme.py b/Examples/test-suite/python/director_extend_runme.py index 1ab58676a..a5aad8245 100644 --- a/Examples/test-suite/python/director_extend_runme.py +++ b/Examples/test-suite/python/director_extend_runme.py @@ -1,20 +1,22 @@ # Test case from bug #1506850 #"When threading is enabled, the interpreter will infinitely wait on a mutex the second -#time this type of extended method is called. Attached is an example -#program that waits on the mutex to be unlocked." +# time this type of extended method is called. Attached is an example +# program that waits on the mutex to be unlocked." from director_extend import * + class MyObject(SpObject): + def __init__(self): SpObject.__init__(self) return def getFoo(self): return 123 - + 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" diff --git a/Examples/test-suite/python/director_finalizer_runme.py b/Examples/test-suite/python/director_finalizer_runme.py index 4cd1f573e..9c9eed693 100644 --- a/Examples/test-suite/python/director_finalizer_runme.py +++ b/Examples/test-suite/python/director_finalizer_runme.py @@ -1,10 +1,14 @@ from director_finalizer import * + class MyFoo(Foo): - def __del__(self): - self.orStatus(2) - try: Foo.__del__(self) - except: pass + + def __del__(self): + self.orStatus(2) + try: + Foo.__del__(self) + except: + pass resetStatus() @@ -13,7 +17,7 @@ a = MyFoo() del a if getStatus() != 3: - raise RuntimeError + raise RuntimeError resetStatus() @@ -21,12 +25,12 @@ a = MyFoo() launder(a) if getStatus() != 0: - raise RuntimeError + raise RuntimeError del a if getStatus() != 3: - raise RuntimeError + raise RuntimeError resetStatus() @@ -34,15 +38,14 @@ a = MyFoo().__disown__() deleteFoo(a) if getStatus() != 3: - raise RuntimeError - + raise RuntimeError + resetStatus() a = MyFoo().__disown__() deleteFoo(launder(a)) if getStatus() != 3: - raise RuntimeError - -resetStatus() + raise RuntimeError +resetStatus() diff --git a/Examples/test-suite/python/director_frob_runme.py b/Examples/test-suite/python/director_frob_runme.py index c2dd734cf..0ef4ad900 100644 --- a/Examples/test-suite/python/director_frob_runme.py +++ b/Examples/test-suite/python/director_frob_runme.py @@ -1,7 +1,7 @@ from director_frob import * -foo = Bravo(); -s = foo.abs_method(); +foo = Bravo() +s = foo.abs_method() if s != "Bravo::abs_method()": - raise RuntimeError, s + raise RuntimeError, s diff --git a/Examples/test-suite/python/director_keywords_runme.py b/Examples/test-suite/python/director_keywords_runme.py index 03a50206a..495d9375e 100644 --- a/Examples/test-suite/python/director_keywords_runme.py +++ b/Examples/test-suite/python/director_keywords_runme.py @@ -2,4 +2,3 @@ from director_keywords import * f = Foo() f.check_self(20) - diff --git a/Examples/test-suite/python/director_nested_runme.py b/Examples/test-suite/python/director_nested_runme.py index cff82f55b..f3d973630 100644 --- a/Examples/test-suite/python/director_nested_runme.py +++ b/Examples/test-suite/python/director_nested_runme.py @@ -2,62 +2,63 @@ from director_nested import * class A(FooBar_int): - def do_step(self): - return "A::do_step;" - - def get_value(self): - return "A::get_value" - pass + def do_step(self): + return "A::do_step;" + + def get_value(self): + return "A::get_value" + + pass a = A() if a.step() != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;": - raise RuntimeError,"Bad A virtual resolution" + raise RuntimeError, "Bad A virtual resolution" class B(FooBar_int): - def do_advance(self): - return "B::do_advance;" + self.do_step() - def do_step(self): - return "B::do_step;" - - def get_value(self): - return 1 + def do_advance(self): + return "B::do_advance;" + self.do_step() - pass + def do_step(self): + return "B::do_step;" + + def get_value(self): + return 1 + + pass b = B() if b.step() != "Bar::step;Foo::advance;B::do_advance;B::do_step;": - raise RuntimeError,"Bad B virtual resolution" - + raise RuntimeError, "Bad B virtual resolution" class C(FooBar_int): - def do_advance(self): - return "C::do_advance;" + FooBar_int.do_advance(self) - def do_step(self): - return "C::do_step;" - - def get_value(self): - return 2 + def do_advance(self): + return "C::do_advance;" + FooBar_int.do_advance(self) - def get_name(self): - return FooBar_int.get_name(self) + " hello" + def do_step(self): + return "C::do_step;" - - pass + def get_value(self): + return 2 + + def get_name(self): + return FooBar_int.get_name(self) + " hello" + + pass cc = C() c = FooBar_int_get_self(cc) c.advance() if c.get_name() != "FooBar::get_name hello": - raise RuntimeError + raise RuntimeError if c.name() != "FooBar::get_name hello": - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/director_profile_runme.py b/Examples/test-suite/python/director_profile_runme.py index 2f67481f5..035007c61 100644 --- a/Examples/test-suite/python/director_profile_runme.py +++ b/Examples/test-suite/python/director_profile_runme.py @@ -1,9 +1,10 @@ import director_profile -class MyB(director_profile.B): - def vfi(self, a): - return a+3 +class MyB(director_profile.B): + + def vfi(self, a): + return a + 3 a = director_profile.A() @@ -15,27 +16,26 @@ fi = b.fi i = 50000 a = 1 while i: - a = fi(a) #1 - a = fi(a) #2 - a = fi(a) #3 - a = fi(a) #4 - a = fi(a) #5 - a = fi(a) #6 - a = fi(a) #7 - a = fi(a) #8 - a = fi(a) #9 - a = fi(a) #10 - a = fi(a) #1 - a = fi(a) #2 - a = fi(a) #3 - a = fi(a) #4 - a = fi(a) #5 - a = fi(a) #6 - a = fi(a) #7 - a = fi(a) #8 - a = fi(a) #9 - a = fi(a) #20 - i -= 1 + a = fi(a) # 1 + a = fi(a) # 2 + a = fi(a) # 3 + a = fi(a) # 4 + a = fi(a) # 5 + a = fi(a) # 6 + a = fi(a) # 7 + a = fi(a) # 8 + a = fi(a) # 9 + a = fi(a) # 10 + a = fi(a) # 1 + a = fi(a) # 2 + a = fi(a) # 3 + a = fi(a) # 4 + a = fi(a) # 5 + a = fi(a) # 6 + a = fi(a) # 7 + a = fi(a) # 8 + a = fi(a) # 9 + a = fi(a) # 20 + i -= 1 print a - diff --git a/Examples/test-suite/python/director_property_runme.py b/Examples/test-suite/python/director_property_runme.py index 303e53b67..5d713c27f 100644 --- a/Examples/test-suite/python/director_property_runme.py +++ b/Examples/test-suite/python/director_property_runme.py @@ -1,18 +1,19 @@ import director_property -class PyFoo(director_property.Foo): - a = property(director_property.Foo.getA, director_property.Foo.setA) - def ping(self): - return "PyFoo::ping()" +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 + raise RuntimeError foo.a = "BIBI" if foo.a != "BIBI": - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/director_protected_runme.py b/Examples/test-suite/python/director_protected_runme.py index fd3c868a1..c3118a7c0 100644 --- a/Examples/test-suite/python/director_protected_runme.py +++ b/Examples/test-suite/python/director_protected_runme.py @@ -1,129 +1,132 @@ from director_protected import * - class FooBar(Bar): - def ping(self): - return "FooBar::ping();" + + def ping(self): + return "FooBar::ping();" + class FooBar2(Bar): - def ping(self): - return "FooBar2::ping();" - def pang(self): - return "FooBar2::pang();" + + def ping(self): + return "FooBar2::ping();" + + def pang(self): + return "FooBar2::pang();" + class FooBar3(Bar): - def cheer(self): - return "FooBar3::cheer();" + + def cheer(self): + return "FooBar3::cheer();" -b = Bar() -f = b.create() +b = Bar() +f = b.create() fb = FooBar() fb2 = FooBar2() fb3 = FooBar3() try: - s = fb.used() - if s != "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();": - raise RuntimeError - pass + s = fb.used() + if s != "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();": + raise RuntimeError + pass except: - raise RuntimeError, "bad FooBar::used" + raise RuntimeError, "bad FooBar::used" try: - s = fb2.used() - if s != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();": - raise RuntimeError - pass + s = fb2.used() + if s != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();": + raise RuntimeError + pass except: - raise RuntimeError, "bad FooBar2::used" + raise RuntimeError, "bad FooBar2::used" try: - s = b.pong() - if s != "Bar::pong();Foo::pong();Bar::ping();": - raise RuntimeError - pass + s = b.pong() + if s != "Bar::pong();Foo::pong();Bar::ping();": + raise RuntimeError + pass except: - raise RuntimeError, "bad Bar::pong" + raise RuntimeError, "bad Bar::pong" try: - s = f.pong() - if s != "Bar::pong();Foo::pong();Bar::ping();": - raise RuntimeError - pass + s = f.pong() + if s != "Bar::pong();Foo::pong();Bar::ping();": + raise RuntimeError + pass except: - raise RuntimeError," bad Foo::pong" - -try: - s = fb.pong() - if s != "Bar::pong();Foo::pong();FooBar::ping();": - raise RuntimeError - pass -except: - raise RuntimeError," bad FooBar::pong" + raise RuntimeError, " bad Foo::pong" -protected=1 try: - b.ping() - protected=0 + s = fb.pong() + if s != "Bar::pong();Foo::pong();FooBar::ping();": + raise RuntimeError + pass except: - pass + raise RuntimeError, " bad FooBar::pong" + +protected = 1 +try: + b.ping() + protected = 0 +except: + pass if not protected: - raise RuntimeError,"Foo::ping is protected" - -protected=1 + raise RuntimeError, "Foo::ping is protected" + +protected = 1 try: - f.ping() - protected=0 + f.ping() + protected = 0 except: - pass + pass if not protected: - raise RuntimeError,"Foo::ping is protected" + raise RuntimeError, "Foo::ping is protected" -protected=1 +protected = 1 try: - f.pang() - protected=0 + f.pang() + protected = 0 except: - pass + pass if not protected: - raise RuntimeError,"FooBar::pang is protected" + raise RuntimeError, "FooBar::pang is protected" -protected=1 +protected = 1 try: - b.cheer() - protected=0 + b.cheer() + protected = 0 except: - pass + pass if not protected: - raise RuntimeError,"Bar::cheer is protected" + raise RuntimeError, "Bar::cheer is protected" -protected=1 +protected = 1 try: - f.cheer() - protected=0 + f.cheer() + protected = 0 except: - pass + pass if not protected: - raise RuntimeError,"Foo::cheer is protected" + raise RuntimeError, "Foo::cheer is protected" if fb3.cheer() != "FooBar3::cheer();": - raise RuntimeError, "bad fb3::cheer" + raise RuntimeError, "bad fb3::cheer" if fb2.callping() != "FooBar2::ping();": - raise RuntimeError, "bad fb2.callping" + raise RuntimeError, "bad fb2.callping" if fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();": - raise RuntimeError, "bad fb2.callcheer" + raise RuntimeError, "bad fb2.callcheer" if fb3.callping() != "Bar::ping();": - raise RuntimeError, "bad fb3.callping" + raise RuntimeError, "bad fb3.callping" if fb3.callcheer() != "FooBar3::cheer();": - raise RuntimeError, "bad fb3.callcheer" - - + raise RuntimeError, "bad fb3.callcheer" diff --git a/Examples/test-suite/python/director_stl_runme.py b/Examples/test-suite/python/director_stl_runme.py index aaea0362a..0c3e5af97 100644 --- a/Examples/test-suite/python/director_stl_runme.py +++ b/Examples/test-suite/python/director_stl_runme.py @@ -1,20 +1,22 @@ import director_stl + class MyFoo(director_stl.Foo): - def ping(self, s): - return "MyFoo::ping():" + s - def pident(self, arg): - return arg - - def vident(self,v): - return v + def ping(self, s): + return "MyFoo::ping():" + s - def vidents(self,v): - return v + def pident(self, arg): + return arg - def vsecond(self,v1,v2): - return v2 + def vident(self, v): + return v + + def vidents(self, v): + return v + + def vsecond(self, v1, v2): + return v2 a = MyFoo() @@ -22,18 +24,18 @@ a = MyFoo() a.tping("hello") a.tpong("hello") -p = (1,2) +p = (1, 2) a.pident(p) -v = (3,4) +v = (3, 4) a.vident(v) a.tpident(p) a.tvident(v) -v1 = (3,4) -v2 = (5,6) -a.tvsecond(v1,v2) +v1 = (3, 4) +v2 = (5, 6) +a.tvsecond(v1, v2) -vs=("hi", "hello") +vs = ("hi", "hello") vs a.tvidents(vs) diff --git a/Examples/test-suite/python/director_string_runme.py b/Examples/test-suite/python/director_string_runme.py index f2db416ca..dcd47d647 100644 --- a/Examples/test-suite/python/director_string_runme.py +++ b/Examples/test-suite/python/director_string_runme.py @@ -1,29 +1,29 @@ from director_string import * + class B(A): - def __init__(self,string): - A.__init__(self,string) - def get_first(self): - return A.get_first(self) + " world!" + def __init__(self, string): + A.__init__(self, string) - def process_text(self, string): - A.process_text(self, string) - self.smem = "hello" - + def get_first(self): + return A.get_first(self) + " world!" + + def process_text(self, string): + A.process_text(self, string) + self.smem = "hello" b = B("hello") b.get(0) if b.get_first() != "hello world!": - print b.get_first() - raise RuntimeError + print b.get_first() + raise RuntimeError b.call_process_func() if b.smem != "hello": - print smem - raise RuntimeError - + print smem + raise RuntimeError diff --git a/Examples/test-suite/python/director_thread_runme.py b/Examples/test-suite/python/director_thread_runme.py index 15a12ab80..4fcf3bfd1 100644 --- a/Examples/test-suite/python/director_thread_runme.py +++ b/Examples/test-suite/python/director_thread_runme.py @@ -1,6 +1,8 @@ from director_thread import Foo -class Derived(Foo) : + +class Derived(Foo): + def __init__(self): Foo.__init__(self) diff --git a/Examples/test-suite/python/director_unroll_runme.py b/Examples/test-suite/python/director_unroll_runme.py index e2bc93779..60bc05585 100644 --- a/Examples/test-suite/python/director_unroll_runme.py +++ b/Examples/test-suite/python/director_unroll_runme.py @@ -1,8 +1,10 @@ import director_unroll + class MyFoo(director_unroll.Foo): - def ping(self): - return "MyFoo::ping()" + + def ping(self): + return "MyFoo::ping()" a = MyFoo() @@ -14,6 +16,5 @@ c = b.get() if not (a.this == c.this): - print a, c - raise RuntimeError - + print a, c + raise RuntimeError diff --git a/Examples/test-suite/python/director_wstring_runme.py b/Examples/test-suite/python/director_wstring_runme.py index f3f29de5e..242b27582 100644 --- a/Examples/test-suite/python/director_wstring_runme.py +++ b/Examples/test-suite/python/director_wstring_runme.py @@ -1,28 +1,28 @@ from director_wstring import * + class B(A): - def __init__(self,string): - A.__init__(self,string) - def get_first(self): - return A.get_first(self) + u" world!" + def __init__(self, string): + A.__init__(self, string) - def process_text(self, string): - self.smem = u"hello" - + def get_first(self): + return A.get_first(self) + u" world!" + + def process_text(self, string): + self.smem = u"hello" b = B(u"hello") b.get(0) if b.get_first() != u"hello world!": - print b.get_first() - raise RuntimeError + print b.get_first() + raise RuntimeError b.call_process_func() if b.smem != u"hello": - print smem - raise RuntimeError - + print smem + raise RuntimeError diff --git a/Examples/test-suite/python/disown_runme.py b/Examples/test-suite/python/disown_runme.py index b8cae077a..1f355f040 100644 --- a/Examples/test-suite/python/disown_runme.py +++ b/Examples/test-suite/python/disown_runme.py @@ -14,7 +14,7 @@ if (not a.thisown): a.thisown = tmp if (a.thisown != tmp): - raise RuntimeError + raise RuntimeError b = B() diff --git a/Examples/test-suite/python/dynamic_cast_runme.py b/Examples/test-suite/python/dynamic_cast_runme.py index 68b06db50..59e86d34c 100644 --- a/Examples/test-suite/python/dynamic_cast_runme.py +++ b/Examples/test-suite/python/dynamic_cast_runme.py @@ -9,4 +9,3 @@ y = b.blah() a = dynamic_cast.do_test(y) if a != "Bar::test": print "Failed!!" - diff --git a/Examples/test-suite/python/enum_forward_runme.py b/Examples/test-suite/python/enum_forward_runme.py index 9af476f97..130ba715b 100644 --- a/Examples/test-suite/python/enum_forward_runme.py +++ b/Examples/test-suite/python/enum_forward_runme.py @@ -1,10 +1,10 @@ import enum_forward - -f1 = enum_forward.get_enum1(); -f1 = enum_forward.test_function1(f1); -f2 = enum_forward.get_enum2(); -f2 = enum_forward.test_function2(f2); +f1 = enum_forward.get_enum1() +f1 = enum_forward.test_function1(f1) -f3 = enum_forward.get_enum3(); -f3 = enum_forward.test_function3(f3); +f2 = enum_forward.get_enum2() +f2 = enum_forward.test_function2(f2) + +f3 = enum_forward.get_enum3() +f3 = enum_forward.test_function3(f3) diff --git a/Examples/test-suite/python/enum_template_runme.py b/Examples/test-suite/python/enum_template_runme.py index 6ad0a8060..64d06ce87 100644 --- a/Examples/test-suite/python/enum_template_runme.py +++ b/Examples/test-suite/python/enum_template_runme.py @@ -1,7 +1,6 @@ import enum_template if enum_template.MakeETest() != 1: - raise RuntimeError + raise RuntimeError if enum_template.TakeETest(0) != None: - raise RuntimeError - + raise RuntimeError diff --git a/Examples/test-suite/python/enums_runme.py b/Examples/test-suite/python/enums_runme.py index 8d491baf4..4870d7c52 100644 --- a/Examples/test-suite/python/enums_runme.py +++ b/Examples/test-suite/python/enums_runme.py @@ -6,14 +6,13 @@ _enums.bar3(1) _enums.bar1(1) if _enums.cvar.enumInstance != 2: - raise RuntimeError + raise RuntimeError if _enums.cvar.Slap != 10: - raise RuntimeError + raise RuntimeError if _enums.cvar.Mine != 11: - raise RuntimeError + raise RuntimeError if _enums.cvar.Thigh != 12: - raise RuntimeError - + raise RuntimeError diff --git a/Examples/test-suite/python/exception_order_runme.py b/Examples/test-suite/python/exception_order_runme.py index 8f095eb98..c53521e3e 100644 --- a/Examples/test-suite/python/exception_order_runme.py +++ b/Examples/test-suite/python/exception_order_runme.py @@ -3,43 +3,42 @@ 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) + exit(0) a = A() try: - a.foo() -except E1,e: - pass + a.foo() +except E1, e: + pass except: - raise RuntimeError, "bad exception order" + raise RuntimeError, "bad exception order" try: - a.bar() -except E2,e: - pass + a.bar() +except E2, e: + pass except: - raise RuntimeError, "bad exception order" + raise RuntimeError, "bad exception order" try: - a.foobar() -except RuntimeError,e: - if e.args[0] != "postcatch unknown": - print "bad exception order", - raise RuntimeError, e.args - + a.foobar() +except RuntimeError, e: + if e.args[0] != "postcatch unknown": + print "bad exception order", + raise RuntimeError, e.args try: - a.barfoo(1) -except E1,e: - pass + a.barfoo(1) +except E1, e: + pass except: - raise RuntimeError, "bad exception order" + raise RuntimeError, "bad exception order" try: - a.barfoo(2) -except E2,e: - pass + a.barfoo(2) +except E2, e: + pass except: - raise RuntimeError, "bad exception order" + raise RuntimeError, "bad exception order" diff --git a/Examples/test-suite/python/extend_placement_runme.py b/Examples/test-suite/python/extend_placement_runme.py index 97b7b1654..2c0be2c31 100644 --- a/Examples/test-suite/python/extend_placement_runme.py +++ b/Examples/test-suite/python/extend_placement_runme.py @@ -2,12 +2,12 @@ import extend_placement foo = extend_placement.Foo() foo = extend_placement.Foo(1) -foo = extend_placement.Foo(1,1) +foo = extend_placement.Foo(1, 1) foo.spam() foo.spam("hello") foo.spam(1) -foo.spam(1,1) -foo.spam(1,1,1) +foo.spam(1, 1) +foo.spam(1, 1, 1) foo.spam(extend_placement.Foo()) foo.spam(extend_placement.Foo(), 1.0) @@ -17,20 +17,20 @@ bar = extend_placement.Bar(1) bar.spam() bar.spam("hello") bar.spam(1) -bar.spam(1,1) -bar.spam(1,1,1) +bar.spam(1, 1) +bar.spam(1, 1, 1) bar.spam(extend_placement.Bar()) bar.spam(extend_placement.Bar(), 1.0) foo = extend_placement.FooTi() foo = extend_placement.FooTi(1) -foo = extend_placement.FooTi(1,1) +foo = extend_placement.FooTi(1, 1) foo.spam() foo.spam("hello") foo.spam(1) -foo.spam(1,1) -foo.spam(1,1,1) +foo.spam(1, 1) +foo.spam(1, 1, 1) foo.spam(extend_placement.Foo()) foo.spam(extend_placement.Foo(), 1.0) @@ -40,7 +40,7 @@ bar = extend_placement.BarTi(1) bar.spam() bar.spam("hello") bar.spam(1) -bar.spam(1,1) -bar.spam(1,1,1) +bar.spam(1, 1) +bar.spam(1, 1, 1) bar.spam(extend_placement.Bar()) bar.spam(extend_placement.Bar(), 1.0) diff --git a/Examples/test-suite/python/extern_c_runme.py b/Examples/test-suite/python/extern_c_runme.py index 1a6d2aa12..91a218a87 100644 --- a/Examples/test-suite/python/extern_c_runme.py +++ b/Examples/test-suite/python/extern_c_runme.py @@ -1,4 +1,3 @@ import extern_c extern_c.RealFunction(2) - diff --git a/Examples/test-suite/python/file_test_runme.py b/Examples/test-suite/python/file_test_runme.py index 9b94fa3b3..33ada500b 100644 --- a/Examples/test-suite/python/file_test_runme.py +++ b/Examples/test-suite/python/file_test_runme.py @@ -2,7 +2,7 @@ import sys import file_test if sys.version_info[0:2] < (3, 0): - file_test.nfile(sys.stdout) + file_test.nfile(sys.stdout) cstdout = file_test.GetStdOut() diff --git a/Examples/test-suite/python/friends_runme.py b/Examples/test-suite/python/friends_runme.py index 04897655a..2d377fdd1 100644 --- a/Examples/test-suite/python/friends_runme.py +++ b/Examples/test-suite/python/friends_runme.py @@ -2,27 +2,36 @@ import friends a = friends.A(2) -if friends.get_val1(a) != 2: raise RuntimeError -if friends.get_val2(a) != 4: raise RuntimeError -if friends.get_val3(a) != 6: raise RuntimeError +if friends.get_val1(a) != 2: + raise RuntimeError +if friends.get_val2(a) != 4: + raise RuntimeError +if friends.get_val3(a) != 6: + raise RuntimeError # nice overload working fine -if friends.get_val1(1,2,3) != 1: raise RuntimeError +if friends.get_val1(1, 2, 3) != 1: + raise RuntimeError b = friends.B(3) # David's case -if friends.mix(a,b) != 5: raise RuntimeError +if friends.mix(a, b) != 5: + raise RuntimeError di = friends.D_d(2) dd = friends.D_d(3.3) # incredible template overloading working just fine -if friends.get_val1(di) != 2: raise RuntimeError -if friends.get_val1(dd) != 3.3: raise RuntimeError +if friends.get_val1(di) != 2: + raise RuntimeError +if friends.get_val1(dd) != 3.3: + raise RuntimeError friends.set(di, 4) friends.set(dd, 1.3) -if friends.get_val1(di) != 4: raise RuntimeError -if friends.get_val1(dd) != 1.3: raise RuntimeError +if friends.get_val1(di) != 4: + raise RuntimeError +if friends.get_val1(dd) != 1.3: + raise RuntimeError diff --git a/Examples/test-suite/python/funcptr_cpp_runme.py b/Examples/test-suite/python/funcptr_cpp_runme.py index ae8616e94..08e85ad7b 100644 --- a/Examples/test-suite/python/funcptr_cpp_runme.py +++ b/Examples/test-suite/python/funcptr_cpp_runme.py @@ -1,9 +1,8 @@ from funcptr_cpp import * if call1(ADD_BY_VALUE, 10, 11) != 21: - raise RuntimeError + raise RuntimeError if call2(ADD_BY_POINTER, 12, 13) != 25: - raise RuntimeError + raise RuntimeError if call3(ADD_BY_REFERENCE, 14, 15) != 29: - raise RuntimeError - + raise RuntimeError diff --git a/Examples/test-suite/python/fvirtual_runme.py b/Examples/test-suite/python/fvirtual_runme.py index ada3313de..99f5dc6b0 100644 --- a/Examples/test-suite/python/fvirtual_runme.py +++ b/Examples/test-suite/python/fvirtual_runme.py @@ -2,8 +2,7 @@ from fvirtual import * sw = NodeSwitch() n = Node() -i = sw.addChild(n); +i = sw.addChild(n) if i != 2: - raise RuntimeError, "addChild" - + raise RuntimeError, "addChild" diff --git a/Examples/test-suite/python/global_functions_runme.py b/Examples/test-suite/python/global_functions_runme.py index 17b70b725..f411261b6 100644 --- a/Examples/test-suite/python/global_functions_runme.py +++ b/Examples/test-suite/python/global_functions_runme.py @@ -1,52 +1,52 @@ from global_functions import * + def check(a, b): - if a != b: - raise RuntimeError("Failed: " + str(a) + " != " + str(b)) + if a != b: + raise RuntimeError("Failed: " + str(a) + " != " + str(b)) global_void() check(global_one(1), 1) check(global_two(2, 2), 4) fail = True try: - global_void(1) + global_void(1) except TypeError, e: - fail = False + fail = False if fail: - raise RuntimeError("argument count check failed") + raise RuntimeError("argument count check failed") fail = True try: - global_one() + global_one() except TypeError, e: - fail = False + fail = False if fail: - raise RuntimeError("argument count check failed") + raise RuntimeError("argument count check failed") fail = True try: - global_one(2, 2) + global_one(2, 2) except TypeError, e: - fail = False + fail = False if fail: - raise RuntimeError("argument count check failed") + raise RuntimeError("argument count check failed") fail = True try: - global_two(1) + global_two(1) except TypeError, e: - fail = False + fail = False if fail: - raise RuntimeError("argument count check failed") + raise RuntimeError("argument count check failed") fail = True try: - global_two(3, 3, 3) + global_two(3, 3, 3) except TypeError, e: - fail = False + fail = False if fail: - raise RuntimeError("argument count check failed") - + raise RuntimeError("argument count check failed") diff --git a/Examples/test-suite/python/global_namespace_runme.py b/Examples/test-suite/python/global_namespace_runme.py index 8e42e0653..ac12fe2dc 100644 --- a/Examples/test-suite/python/global_namespace_runme.py +++ b/Examples/test-suite/python/global_namespace_runme.py @@ -1,7 +1,8 @@ from global_namespace import * + def is_new_style_class(cls): - return hasattr(cls, "__class__") + return hasattr(cls, "__class__") k1 = Klass1() k2 = Klass2() @@ -12,9 +13,9 @@ k6 = Klass6() k7 = Klass7() if is_new_style_class(KlassMethods): - KlassMethods_static = KlassMethods + KlassMethods_static = KlassMethods else: - KlassMethods_static = KlassMethods() + KlassMethods_static = KlassMethods() KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7) KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7) @@ -41,15 +42,17 @@ KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7) KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7) if is_new_style_class(XYZMethods): - XYZMethods_static = XYZMethods + XYZMethods_static = XYZMethods else: - XYZMethods_static = XYZMethods() -XYZMethods_static.methodA(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7()) -XYZMethods_static.methodB(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7()) + XYZMethods_static = XYZMethods() +XYZMethods_static.methodA( + XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7()) +XYZMethods_static.methodB( + XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7()) if is_new_style_class(TheEnumMethods): - TheEnumMethods_static = TheEnumMethods + TheEnumMethods_static = TheEnumMethods else: - TheEnumMethods_static = TheEnumMethods() + TheEnumMethods_static = TheEnumMethods() TheEnumMethods_static.methodA(theenum1, theenum2, theenum3) TheEnumMethods_static.methodA(theenum1, theenum2, theenum3) diff --git a/Examples/test-suite/python/global_ns_arg_runme.py b/Examples/test-suite/python/global_ns_arg_runme.py index cf1915648..f7fbc7a9e 100644 --- a/Examples/test-suite/python/global_ns_arg_runme.py +++ b/Examples/test-suite/python/global_ns_arg_runme.py @@ -2,4 +2,3 @@ from global_ns_arg import * a = foo(1) b = bar_fn() - diff --git a/Examples/test-suite/python/global_vars_runme.py b/Examples/test-suite/python/global_vars_runme.py index 5d520b5ce..3ef0b494f 100644 --- a/Examples/test-suite/python/global_vars_runme.py +++ b/Examples/test-suite/python/global_vars_runme.py @@ -3,33 +3,32 @@ import global_vars global_vars.init() b = global_vars.cvar.b if b != "string b": - raise RuntimeError("Unexpected string: " + b) + raise RuntimeError("Unexpected string: " + b) global_vars.cvar.b = "a string value" b = global_vars.cvar.b if b != "a string value": - raise RuntimeError("Unexpected string: " + b) + raise RuntimeError("Unexpected string: " + b) x = global_vars.cvar.x if x != 1234: - raise RuntimeError("Unexpected x: " + str(x)) + raise RuntimeError("Unexpected x: " + str(x)) global_vars.cvar.x = 9876 x = global_vars.cvar.x if x != 9876: - raise RuntimeError("Unexpected string: " + str(x)) + raise RuntimeError("Unexpected string: " + str(x)) fail = True try: - global_vars.cvar.notexist = "something" + global_vars.cvar.notexist = "something" except AttributeError, e: - fail = False + fail = False if fail: - raise RuntimeError("AttributeError should have been thrown") + raise RuntimeError("AttributeError should have been thrown") fail = True try: - g = global_vars.cvar.notexist + g = global_vars.cvar.notexist except AttributeError, e: - fail = False + fail = False if fail: - raise RuntimeError("AttributeError should have been thrown") - + raise RuntimeError("AttributeError should have been thrown") diff --git a/Examples/test-suite/python/iadd_runme.py b/Examples/test-suite/python/iadd_runme.py index fbeb0ec3e..ceaa38860 100644 --- a/Examples/test-suite/python/iadd_runme.py +++ b/Examples/test-suite/python/iadd_runme.py @@ -3,7 +3,7 @@ import iadd f = iadd.Foo() f.AsA.x = 3 -f.AsA += f.AsA +f.AsA += f.AsA if f.AsA.x != 6: raise RuntimeError diff --git a/Examples/test-suite/python/implicittest_runme.py b/Examples/test-suite/python/implicittest_runme.py index 4cad1bb5d..4646d08c0 100644 --- a/Examples/test-suite/python/implicittest_runme.py +++ b/Examples/test-suite/python/implicittest_runme.py @@ -1,11 +1,13 @@ from implicittest import * + def check(a, b): if a != b: raise RuntimeError(str(a) + " does not equal " + str(b)) + def is_new_style_class(cls): - return hasattr(cls, "__class__") + return hasattr(cls, "__class__") #### Class #### @@ -20,7 +22,8 @@ try: except ValueError: # ValueError: invalid null reference in method 'new_A', argument 1 of type 'B const &' # Arguably A(char *) should be chosen, but there is a bug to do with None passed to methods overloaded by value, - # references and pointers to different types, where pointers ought to be given a slightly higher precedence. + # references and pointers to different types, where pointers ought to be + # given a slightly higher precedence. pass check(1, get(1)) @@ -43,9 +46,9 @@ check(3, A_int(B()).get()) check(4, A_int("hello").get()) if is_new_style_class(A_int): - A_int_static = A_int + A_int_static = A_int else: - A_int_static = A_int(0) + A_int_static = A_int(0) check(1, A_int_static.sget(1)) check(2, A_int_static.sget(1.0)) check(3, A_int_static.sget(B())) @@ -59,10 +62,14 @@ except TypeError: #### Global variable assignment #### -cvar.foo = Foo(1); check(cvar.foo.ii, 1) -cvar.foo = 1; check(cvar.foo.ii, 1) -cvar.foo = 1.0; check(cvar.foo.ii, 2) -cvar.foo = Foo("hello"); check(cvar.foo.ii, 3) +cvar.foo = Foo(1) +check(cvar.foo.ii, 1) +cvar.foo = 1 +check(cvar.foo.ii, 1) +cvar.foo = 1.0 +check(cvar.foo.ii, 2) +cvar.foo = Foo("hello") +check(cvar.foo.ii, 3) # explicit constructor: try: @@ -74,10 +81,14 @@ except TypeError: #### Member variable assignment #### # Note: also needs naturalvar -b = Bar(); check(b.f.ii, 0) -b.f = Foo("hello"); check(b.f.ii, 3) -b.f = 1; check(b.f.ii, 1) -b.f = 1.0; check(b.f.ii, 2) +b = Bar() +check(b.f.ii, 0) +b.f = Foo("hello") +check(b.f.ii, 3) +b.f = 1 +check(b.f.ii, 1) +b.f = 1.0 +check(b.f.ii, 2) # explicit constructor: try: @@ -129,4 +140,3 @@ ccc = CCC(B()) check(ccc.checkvalue, 10) check(ccc.xx(123), 11) check(ccc.yy(123, 123), 111) - diff --git a/Examples/test-suite/python/import_nomodule_runme.py b/Examples/test-suite/python/import_nomodule_runme.py index efcff9c48..e43c233b4 100644 --- a/Examples/test-suite/python/import_nomodule_runme.py +++ b/Examples/test-suite/python/import_nomodule_runme.py @@ -3,11 +3,11 @@ 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) + exit(0) f = create_Foo() -test1(f,42) +test1(f, 42) delete_Foo(f) b = Bar() -test1(b,37) +test1(b, 37) diff --git a/Examples/test-suite/python/import_stl_runme.py b/Examples/test-suite/python/import_stl_runme.py index 90c411455..69fe812b9 100644 --- a/Examples/test-suite/python/import_stl_runme.py +++ b/Examples/test-suite/python/import_stl_runme.py @@ -1,7 +1,6 @@ import import_stl_b import import_stl_a -v_new = import_stl_b.process_vector([1,2,3]) -if v_new != (1,2,3,4): - raise RuntimeError, v_new - +v_new = import_stl_b.process_vector([1, 2, 3]) +if v_new != (1, 2, 3, 4): + raise RuntimeError, v_new diff --git a/Examples/test-suite/python/imports_runme.py b/Examples/test-suite/python/imports_runme.py index 50a3ab59f..3eec965a6 100644 --- a/Examples/test-suite/python/imports_runme.py +++ b/Examples/test-suite/python/imports_runme.py @@ -14,4 +14,4 @@ a1 = c.get_a(c) a2 = c.get_a_type(c) if a1.hello() != a2.hello(): - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/inctest_runme.py b/Examples/test-suite/python/inctest_runme.py index e10f4544c..fa3492932 100644 --- a/Examples/test-suite/python/inctest_runme.py +++ b/Examples/test-suite/python/inctest_runme.py @@ -2,31 +2,30 @@ import inctest error = 0 try: - a = inctest.A() + a = inctest.A() except: - print "didn't find A" - print "therefore, I didn't include 'testdir/subdir1/hello.i'" - error = 1 + print "didn't find A" + print "therefore, I didn't include 'testdir/subdir1/hello.i'" + error = 1 pass try: - b = inctest.B() + b = inctest.B() except: - print "didn't find B" - print "therefore, I didn't include 'testdir/subdir2/hello.i'" - error = 1 + print "didn't find B" + print "therefore, I didn't include 'testdir/subdir2/hello.i'" + error = 1 pass if error == 1: - raise RuntimeError + raise RuntimeError # Check the import in subdirectory worked if inctest.importtest1(5) != 15: - print "import test 1 failed" - raise RuntimeError + print "import test 1 failed" + raise RuntimeError if inctest.importtest2("black") != "white": - print "import test 2 failed" - raise RuntimeError - + print "import test 2 failed" + raise RuntimeError diff --git a/Examples/test-suite/python/inout_runme.py b/Examples/test-suite/python/inout_runme.py index fb290f62f..bb198d774 100644 --- a/Examples/test-suite/python/inout_runme.py +++ b/Examples/test-suite/python/inout_runme.py @@ -2,21 +2,20 @@ import inout a = inout.AddOne1(1) if a != 2: - raise RuntimeError + raise RuntimeError -a = inout.AddOne3(1,1,1) -if a != [2,2,2]: - raise RuntimeError +a = inout.AddOne3(1, 1, 1) +if a != [2, 2, 2]: + raise RuntimeError -a = inout.AddOne1p((1,1)) -if a != (2,2): - raise RuntimeError +a = inout.AddOne1p((1, 1)) +if a != (2, 2): + raise RuntimeError -a = inout.AddOne2p((1,1),1) -if a != [(2,2),2]: - raise RuntimeError - -a = inout.AddOne3p(1,(1,1),1) -if a != [2,(2,2),2]: - raise RuntimeError +a = inout.AddOne2p((1, 1), 1) +if a != [(2, 2), 2]: + raise RuntimeError +a = inout.AddOne3p(1, (1, 1), 1) +if a != [2, (2, 2), 2]: + raise RuntimeError diff --git a/Examples/test-suite/python/inplaceadd_runme.py b/Examples/test-suite/python/inplaceadd_runme.py index b703c56c7..7f292cbb5 100644 --- a/Examples/test-suite/python/inplaceadd_runme.py +++ b/Examples/test-suite/python/inplaceadd_runme.py @@ -3,18 +3,18 @@ a = inplaceadd.A(7) a += 5 if a.val != 12: - print a.val - raise RuntimeError + print a.val + raise RuntimeError a -= 5 if a.val != 7: - raise RuntimeError + raise RuntimeError a *= 2 if a.val != 14: - raise RuntimeError + raise RuntimeError a += a if a.val != 28: - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/input_runme.py b/Examples/test-suite/python/input_runme.py index f5ef6dc8b..1a06e8b7b 100644 --- a/Examples/test-suite/python/input_runme.py +++ b/Examples/test-suite/python/input_runme.py @@ -2,19 +2,19 @@ from input import * f = Foo() if f.foo(2) != 4: - raise RuntimeError - -if f.foo(None)!= None: - raise RuntimeError + raise RuntimeError -if f.foo()!= None: - raise RuntimeError +if f.foo(None) != None: + raise RuntimeError + +if f.foo() != None: + raise RuntimeError if sfoo("Hello") != "Hello world": - raise RuntimeError + raise RuntimeError if sfoo(None) != None: - raise RuntimeError + raise RuntimeError if sfoo() != None: - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/kwargs_feature_runme.py b/Examples/test-suite/python/kwargs_feature_runme.py index 37457c976..a2d4731ab 100644 --- a/Examples/test-suite/python/kwargs_feature_runme.py +++ b/Examples/test-suite/python/kwargs_feature_runme.py @@ -1,81 +1,81 @@ from kwargs_feature import * -class MyFoo(Foo): - def __init__(self, a , b = 0): - Foo.__init__(self, a, b) - +class MyFoo(Foo): + + def __init__(self, a, b=0): + Foo.__init__(self, a, b) + # Simple class f1 = MyFoo(2) -f = Foo(b=2,a=1) +f = Foo(b=2, a=1) -if f.foo(b=1,a=2) != 3: - raise RuntimeError +if f.foo(b=1, a=2) != 3: + raise RuntimeError if Foo_statfoo(b=2) != 3: - raise RuntimeError + raise RuntimeError if f.efoo(b=2) != 3: - raise RuntimeError + raise RuntimeError if Foo_sfoo(b=2) != 3: - raise RuntimeError + raise RuntimeError # Templated class -b = BarInt(b=2,a=1) +b = BarInt(b=2, a=1) -if b.bar(b=1,a=2) != 3: - raise RuntimeError +if b.bar(b=1, a=2) != 3: + raise RuntimeError if BarInt_statbar(b=2) != 3: - raise RuntimeError + raise RuntimeError if b.ebar(b=2) != 3: - raise RuntimeError + raise RuntimeError if BarInt_sbar(b=2) != 3: - raise RuntimeError + raise RuntimeError # Functions if templatedfunction(b=2) != 3: - raise RuntimeError + raise RuntimeError -if foo_fn(a=1,b=2) != 3: - raise RuntimeError +if foo_fn(a=1, b=2) != 3: + raise RuntimeError if foo_fn(b=2) != 3: - raise RuntimeError + raise RuntimeError -#Functions with keywords +# Functions with keywords if foo_kw(_from=2) != 4: - raise RuntimeError + raise RuntimeError if foo_nu(_from=2, arg2=3) != 2: - raise RuntimeError + raise RuntimeError if foo_mm(min=2) != 4: - raise RuntimeError + raise RuntimeError if foo_mm(max=3) != 4: - raise RuntimeError - -#Default args with references + raise RuntimeError + +# Default args with references if rfoo(n=123) != 120: - raise RuntimeError + raise RuntimeError if rfoo(x=10) != -10: - raise RuntimeError + raise RuntimeError if rfoo(n=11, x=22) != -11: - raise RuntimeError + raise RuntimeError if rfoo(x=11, n=22) != 11: - raise RuntimeError - + raise RuntimeError diff --git a/Examples/test-suite/python/langobj_runme.py b/Examples/test-suite/python/langobj_runme.py index c10e19303..b32d5a18a 100644 --- a/Examples/test-suite/python/langobj_runme.py +++ b/Examples/test-suite/python/langobj_runme.py @@ -2,7 +2,7 @@ import sys from langobj import * -x ="hello" +x = "hello" rx = sys.getrefcount(x) v = identity(x) rv = sys.getrefcount(v) diff --git a/Examples/test-suite/python/li_attribute_runme.py b/Examples/test-suite/python/li_attribute_runme.py index db40b9b2a..13a01c97d 100644 --- a/Examples/test-suite/python/li_attribute_runme.py +++ b/Examples/test-suite/python/li_attribute_runme.py @@ -2,73 +2,72 @@ import li_attribute -aa = li_attribute.A(1,2,3) +aa = li_attribute.A(1, 2, 3) if aa.a != 1: - raise RuntimeError + raise RuntimeError aa.a = 3 if aa.a != 3: - print aa.a - raise RuntimeError + print aa.a + raise RuntimeError if aa.b != 2: - print aa.b - raise RuntimeError + print aa.b + raise RuntimeError aa.b = 5 if aa.b != 5: - raise RuntimeError + raise RuntimeError if aa.d != aa.b: - raise RuntimeError + raise RuntimeError if aa.c != 3: - raise RuntimeError + raise RuntimeError #aa.c = 5 -#if aa.c != 3: +# if aa.c != 3: # raise RuntimeError pi = li_attribute.Param_i(7) if pi.value != 7: - raise RuntimeError + raise RuntimeError -pi.value=3 +pi.value = 3 if pi.value != 3: - raise RuntimeError + raise RuntimeError b = li_attribute.B(aa) if b.a.c != 3: - raise RuntimeError - + raise RuntimeError + # class/struct attribute with get/set methods using return/pass by reference myFoo = li_attribute.MyFoo() myFoo.x = 8 myClass = li_attribute.MyClass() myClass.Foo = myFoo if myClass.Foo.x != 8: - raise RuntimeError + raise RuntimeError # class/struct attribute with get/set methods using return/pass by value myClassVal = li_attribute.MyClassVal() if myClassVal.ReadWriteFoo.x != -1: - raise RuntimeError + raise RuntimeError if myClassVal.ReadOnlyFoo.x != -1: - raise RuntimeError + raise RuntimeError myClassVal.ReadWriteFoo = myFoo if myClassVal.ReadWriteFoo.x != 8: - raise RuntimeError + raise RuntimeError if myClassVal.ReadOnlyFoo.x != 8: - raise RuntimeError + raise RuntimeError # string attribute with get/set methods using return/pass by value myStringyClass = li_attribute.MyStringyClass("initial string") if myStringyClass.ReadWriteString != "initial string": - raise RuntimeError + raise RuntimeError if myStringyClass.ReadOnlyString != "initial string": - raise RuntimeError + raise RuntimeError myStringyClass.ReadWriteString = "changed string" if myStringyClass.ReadWriteString != "changed string": - raise RuntimeError + raise RuntimeError if myStringyClass.ReadOnlyString != "changed string": - raise RuntimeError - + 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 7423053f9..d33b12309 100644 --- a/Examples/test-suite/python/li_attribute_template_runme.py +++ b/Examples/test-suite/python/li_attribute_template_runme.py @@ -2,66 +2,67 @@ import li_attribute_template -chell = li_attribute_template.Cintint(1,2,3) +chell = li_attribute_template.Cintint(1, 2, 3) -def rassert( what, master ): + +def rassert(what, master): if what != master: print what raise RuntimeError -## Testing primitive by value attribute -rassert( chell.a, 1 ) +# Testing primitive by value attribute +rassert(chell.a, 1) chell.a = 3 -rassert( chell.a, 3 ) +rassert(chell.a, 3) -## Testing primitive by ref attribute +# Testing primitive by ref attribute -rassert( chell.b, 2 ) +rassert(chell.b, 2) chell.b = 5 -rassert( chell.b,5 ) +rassert(chell.b, 5) -## Testing string +# Testing string chell.str = "abc" -rassert( chell.str, "abc" ) +rassert(chell.str, "abc") # Testing class by value -rassert( chell.d.value, 1 ) +rassert(chell.d.value, 1) chell.d = li_attribute_template.Foo(2) -rassert( chell.d.value, 2 ) +rassert(chell.d.value, 2) # Testing class by reference -rassert( chell.e.value, 2 ) +rassert(chell.e.value, 2) -chell.e= li_attribute_template.Foo(3) -rassert( chell.e.value, 3 ) +chell.e = li_attribute_template.Foo(3) +rassert(chell.e.value, 3) chell.e.value = 4 -rassert( chell.e.value, 4 ) +rassert(chell.e.value, 4) # Testing moderately complex template by value -rassert( chell.f.first, 1 ) -rassert( chell.f.second, 2 ) +rassert(chell.f.first, 1) +rassert(chell.f.second, 2) -pair = li_attribute_template.pair_intint(3,4) +pair = li_attribute_template.pair_intint(3, 4) chell.f = pair -rassert( chell.f.first, 3 ) -rassert( chell.f.second, 4 ) +rassert(chell.f.first, 3) +rassert(chell.f.second, 4) # Testing moderately complex template by ref -rassert( chell.g.first, 2 ) -rassert( chell.g.second, 3 ) +rassert(chell.g.first, 2) +rassert(chell.g.second, 3) -pair = li_attribute_template.pair_intint(4,5) +pair = li_attribute_template.pair_intint(4, 5) chell.g = pair -rassert( chell.g.first, 4 ) -rassert( chell.g.second, 5 ) +rassert(chell.g.first, 4) +rassert(chell.g.second, 5) chell.g.first = 6 chell.g.second = 7 -rassert( chell.g.first, 6 ) -rassert( chell.g.second, 7 ) +rassert(chell.g.first, 6) +rassert(chell.g.second, 7) diff --git a/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py index a05432925..9b9c7d683 100644 --- a/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py +++ b/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py @@ -1,20 +1,22 @@ from li_boost_shared_ptr_bits import * + def is_new_style_class(cls): - return hasattr(cls, "__class__") + return hasattr(cls, "__class__") + def check(nd): - nd.i = 200 - i = nd.i + nd.i = 200 + i = nd.i - try: - nd.notexist = 100 - passed = 0 - except: - passed = 1 + try: + nd.notexist = 100 + passed = 0 + except: + passed = 1 - if not passed: - raise "Test failed" + if not passed: + raise "Test failed" nd = NonDynamic() check(nd) @@ -30,11 +32,10 @@ v.push_back(IntHolder(33)) sum = sum(v) if sum != 66: - raise "sum is wrong" + raise "sum is wrong" ################################ if is_new_style_class(HiddenDestructor): - p = HiddenDestructor.create() + p = HiddenDestructor.create() else: - p = HiddenDestructor_create() - + p = HiddenDestructor_create() diff --git a/Examples/test-suite/python/li_boost_shared_ptr_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_runme.py index 0e025d546..7214add3e 100644 --- a/Examples/test-suite/python/li_boost_shared_ptr_runme.py +++ b/Examples/test-suite/python/li_boost_shared_ptr_runme.py @@ -4,541 +4,559 @@ import gc debug = False # simple shared_ptr usage - created in C++ + + class li_boost_shared_ptr_runme: - def main(self): - if (debug): - print "Started" - - li_boost_shared_ptr.cvar.debug_shared = debug - - # Change loop count to run for a long time to monitor memory - loopCount = 1 #5000 - for i in range (0,loopCount): - self.runtest() - - # Expect 1 instance - the one global variable (GlobalValue) - if (li_boost_shared_ptr.Klass_getTotal_count() != 1): - raise RuntimeError("Klass.total_count=%s" % li_boost_shared_ptr.Klass.getTotal_count()) - - wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count() - if (wrapper_count != li_boost_shared_ptr.NOT_COUNTING): - # Expect 1 instance - the one global variable (GlobalSmartValue) - if (wrapper_count != 1): - raise RuntimeError("shared_ptr wrapper count=%s" % wrapper_count) - - if (debug): - print "Finished" - - def runtest(self): - # simple shared_ptr usage - created in C++ - k = li_boost_shared_ptr.Klass("me oh my") - val = k.getValue() - self.verifyValue("me oh my", val) - self.verifyCount(1, k) - - # simple shared_ptr usage - not created in C++ - k = li_boost_shared_ptr.factorycreate() - val = k.getValue() - self.verifyValue("factorycreate", val) - self.verifyCount(1, k) - - # pass by shared_ptr - k = li_boost_shared_ptr.Klass("me oh my") - kret = li_boost_shared_ptr.smartpointertest(k) - val = kret.getValue() - self.verifyValue("me oh my smartpointertest", val) - self.verifyCount(2, k) - self.verifyCount(2, kret) - - # pass by shared_ptr pointer - k = li_boost_shared_ptr.Klass("me oh my") - kret = li_boost_shared_ptr.smartpointerpointertest(k) - val = kret.getValue() - self.verifyValue("me oh my smartpointerpointertest", val) - self.verifyCount(2, k) - self.verifyCount(2, kret) - - # pass by shared_ptr reference - k = li_boost_shared_ptr.Klass("me oh my") - kret = li_boost_shared_ptr.smartpointerreftest(k) - val = kret.getValue() - self.verifyValue("me oh my smartpointerreftest", val) - self.verifyCount(2, k) - self.verifyCount(2, kret) - - # pass by shared_ptr pointer reference - k = li_boost_shared_ptr.Klass("me oh my") - kret = li_boost_shared_ptr.smartpointerpointerreftest(k) - val = kret.getValue() - self.verifyValue("me oh my smartpointerpointerreftest", val) - self.verifyCount(2, k) - self.verifyCount(2, kret) - - # const pass by shared_ptr - k = li_boost_shared_ptr.Klass("me oh my") - kret = li_boost_shared_ptr.constsmartpointertest(k) - val = kret.getValue() - self.verifyValue("me oh my", val) - self.verifyCount(2, k) - self.verifyCount(2, kret) - - # const pass by shared_ptr pointer - k = li_boost_shared_ptr.Klass("me oh my") - kret = li_boost_shared_ptr.constsmartpointerpointertest(k) - val = kret.getValue() - self.verifyValue("me oh my", val) - self.verifyCount(2, k) - self.verifyCount(2, kret) - - # const pass by shared_ptr reference - k = li_boost_shared_ptr.Klass("me oh my") - kret = li_boost_shared_ptr.constsmartpointerreftest(k) - val = kret.getValue() - self.verifyValue("me oh my", val) - self.verifyCount(2, k) - self.verifyCount(2, kret) - - # pass by value - k = li_boost_shared_ptr.Klass("me oh my") - kret = li_boost_shared_ptr.valuetest(k) - val = kret.getValue() - self.verifyValue("me oh my valuetest", val) - self.verifyCount(1, k) - self.verifyCount(1, kret) - - # pass by pointer - k = li_boost_shared_ptr.Klass("me oh my") - kret = li_boost_shared_ptr.pointertest(k) - val = kret.getValue() - self.verifyValue("me oh my pointertest", val) - self.verifyCount(1, k) - self.verifyCount(1, kret) - - # pass by reference - k = li_boost_shared_ptr.Klass("me oh my") - kret = li_boost_shared_ptr.reftest(k) - val = kret.getValue() - self.verifyValue("me oh my reftest", val) - self.verifyCount(1, k) - self.verifyCount(1, kret) - - # pass by pointer reference - k = li_boost_shared_ptr.Klass("me oh my") - kret = li_boost_shared_ptr.pointerreftest(k) - val = kret.getValue() - self.verifyValue("me oh my pointerreftest", val) - self.verifyCount(1, k) - self.verifyCount(1, kret) - - # null tests - k = None - - if (li_boost_shared_ptr.smartpointertest(k) != None): - raise RuntimeError("return was not null") - - if (li_boost_shared_ptr.smartpointerpointertest(k) != None): - raise RuntimeError("return was not null") - - if (li_boost_shared_ptr.smartpointerreftest(k) != None): - raise RuntimeError("return was not null") - - if (li_boost_shared_ptr.smartpointerpointerreftest(k) != None): - raise RuntimeError("return was not null") - - if (li_boost_shared_ptr.nullsmartpointerpointertest(None) != "null pointer"): - raise RuntimeError("not null smartpointer pointer") - - try: - li_boost_shared_ptr.valuetest(k) - raise RuntimeError("Failed to catch null pointer") - except ValueError: - pass - - if (li_boost_shared_ptr.pointertest(k) != None): - raise RuntimeError("return was not null") - - try: - li_boost_shared_ptr.reftest(k) - raise RuntimeError("Failed to catch null pointer") - except ValueError: - pass - - # $owner - k = li_boost_shared_ptr.pointerownertest() - val = k.getValue() - self.verifyValue("pointerownertest", val) - self.verifyCount(1, k) - k = li_boost_shared_ptr.smartpointerpointerownertest() - val = k.getValue() - self.verifyValue("smartpointerpointerownertest", val) - self.verifyCount(1, k) - - # //////////////////////////////// Derived class //////////////////////////////////////// - # derived pass by shared_ptr - k = li_boost_shared_ptr.KlassDerived("me oh my") - kret = li_boost_shared_ptr.derivedsmartptrtest(k) - val = kret.getValue() - self.verifyValue("me oh my derivedsmartptrtest-Derived", val) - self.verifyCount(2, k) - self.verifyCount(2, kret) - - # derived pass by shared_ptr pointer - k = li_boost_shared_ptr.KlassDerived("me oh my") - kret = li_boost_shared_ptr.derivedsmartptrpointertest(k) - val = kret.getValue() - self.verifyValue("me oh my derivedsmartptrpointertest-Derived", val) - self.verifyCount(2, k) - self.verifyCount(2, kret) - - # derived pass by shared_ptr ref - k = li_boost_shared_ptr.KlassDerived("me oh my") - kret = li_boost_shared_ptr.derivedsmartptrreftest(k) - val = kret.getValue() - self.verifyValue("me oh my derivedsmartptrreftest-Derived", val) - self.verifyCount(2, k) - self.verifyCount(2, kret) - - # derived pass by shared_ptr pointer ref - k = li_boost_shared_ptr.KlassDerived("me oh my") - kret = li_boost_shared_ptr.derivedsmartptrpointerreftest(k) - val = kret.getValue() - self.verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val) - self.verifyCount(2, k) - self.verifyCount(2, kret) - - # derived pass by pointer - k = li_boost_shared_ptr.KlassDerived("me oh my") - kret = li_boost_shared_ptr.derivedpointertest(k) - val = kret.getValue() - self.verifyValue("me oh my derivedpointertest-Derived", val) - self.verifyCount(1, k) - self.verifyCount(1, kret) - - # derived pass by ref - k = li_boost_shared_ptr.KlassDerived("me oh my") - kret = li_boost_shared_ptr.derivedreftest(k) - val = kret.getValue() - self.verifyValue("me oh my derivedreftest-Derived", val) - self.verifyCount(1, k) - self.verifyCount(1, kret) - - # //////////////////////////////// Derived and base class mixed //////////////////////////////////////// - # pass by shared_ptr (mixed) - k = li_boost_shared_ptr.KlassDerived("me oh my") - kret = li_boost_shared_ptr.smartpointertest(k) - val = kret.getValue() - self.verifyValue("me oh my smartpointertest-Derived", val) - self.verifyCount(2, k) - self.verifyCount(2, kret) - - # pass by shared_ptr pointer (mixed) - k = li_boost_shared_ptr.KlassDerived("me oh my") - kret = li_boost_shared_ptr.smartpointerpointertest(k) - val = kret.getValue() - self.verifyValue("me oh my smartpointerpointertest-Derived", val) - self.verifyCount(2, k) - self.verifyCount(2, kret) - - # pass by shared_ptr reference (mixed) - k = li_boost_shared_ptr.KlassDerived("me oh my") - kret = li_boost_shared_ptr.smartpointerreftest(k) - val = kret.getValue() - self.verifyValue("me oh my smartpointerreftest-Derived", val) - self.verifyCount(2, k) - self.verifyCount(2, kret) - - # pass by shared_ptr pointer reference (mixed) - k = li_boost_shared_ptr.KlassDerived("me oh my") - kret = li_boost_shared_ptr.smartpointerpointerreftest(k) - val = kret.getValue() - self.verifyValue("me oh my smartpointerpointerreftest-Derived", val) - self.verifyCount(2, k) - self.verifyCount(2, kret) - - # pass by value (mixed) - k = li_boost_shared_ptr.KlassDerived("me oh my") - kret = li_boost_shared_ptr.valuetest(k) - val = kret.getValue() - self.verifyValue("me oh my valuetest", val) # note slicing - self.verifyCount(1, k) - self.verifyCount(1, kret) - - # pass by pointer (mixed) - k = li_boost_shared_ptr.KlassDerived("me oh my") - kret = li_boost_shared_ptr.pointertest(k) - val = kret.getValue() - self.verifyValue("me oh my pointertest-Derived", val) - self.verifyCount(1, k) - self.verifyCount(1, kret) - - # pass by ref (mixed) - k = li_boost_shared_ptr.KlassDerived("me oh my") - kret = li_boost_shared_ptr.reftest(k) - val = kret.getValue() - self.verifyValue("me oh my reftest-Derived", val) - self.verifyCount(1, k) - self.verifyCount(1, kret) - - # //////////////////////////////// Overloading tests //////////////////////////////////////// - # Base class - k = li_boost_shared_ptr.Klass("me oh my") - self.verifyValue(li_boost_shared_ptr.overload_rawbyval(k), "rawbyval") - self.verifyValue(li_boost_shared_ptr.overload_rawbyref(k), "rawbyref") - self.verifyValue(li_boost_shared_ptr.overload_rawbyptr(k), "rawbyptr") - self.verifyValue(li_boost_shared_ptr.overload_rawbyptrref(k), "rawbyptrref") - - self.verifyValue(li_boost_shared_ptr.overload_smartbyval(k), "smartbyval") - self.verifyValue(li_boost_shared_ptr.overload_smartbyref(k), "smartbyref") - self.verifyValue(li_boost_shared_ptr.overload_smartbyptr(k), "smartbyptr") - self.verifyValue(li_boost_shared_ptr.overload_smartbyptrref(k), "smartbyptrref") - - # Derived class - k = li_boost_shared_ptr.KlassDerived("me oh my") - self.verifyValue(li_boost_shared_ptr.overload_rawbyval(k), "rawbyval") - self.verifyValue(li_boost_shared_ptr.overload_rawbyref(k), "rawbyref") - self.verifyValue(li_boost_shared_ptr.overload_rawbyptr(k), "rawbyptr") - self.verifyValue(li_boost_shared_ptr.overload_rawbyptrref(k), "rawbyptrref") - - self.verifyValue(li_boost_shared_ptr.overload_smartbyval(k), "smartbyval") - self.verifyValue(li_boost_shared_ptr.overload_smartbyref(k), "smartbyref") - self.verifyValue(li_boost_shared_ptr.overload_smartbyptr(k), "smartbyptr") - self.verifyValue(li_boost_shared_ptr.overload_smartbyptrref(k), "smartbyptrref") - - # 3rd derived class - k = li_boost_shared_ptr.Klass3rdDerived("me oh my") - val = k.getValue() - self.verifyValue("me oh my-3rdDerived", val) - self.verifyCount(1, k) - val = li_boost_shared_ptr.test3rdupcast(k) - self.verifyValue("me oh my-3rdDerived", val) - self.verifyCount(1, k) - - # //////////////////////////////// Member variables //////////////////////////////////////// - # smart pointer by value - m = li_boost_shared_ptr.MemberVariables() - k = li_boost_shared_ptr.Klass("smart member value") - m.SmartMemberValue = k - val = k.getValue() - self.verifyValue("smart member value", val) - self.verifyCount(2, k) - - kmember = m.SmartMemberValue - val = kmember.getValue() - self.verifyValue("smart member value", val) - self.verifyCount(3, kmember) - self.verifyCount(3, k) - - del m - self.verifyCount(2, kmember) - self.verifyCount(2, k) - - # smart pointer by pointer - m = li_boost_shared_ptr.MemberVariables() - k = li_boost_shared_ptr.Klass("smart member pointer") - m.SmartMemberPointer = k - val = k.getValue() - self.verifyValue("smart member pointer", val) - self.verifyCount(1, k) - - kmember = m.SmartMemberPointer - val = kmember.getValue() - self.verifyValue("smart member pointer", val) - self.verifyCount(2, kmember) - self.verifyCount(2, k) - - del m - self.verifyCount(2, kmember) - self.verifyCount(2, k) - - # smart pointer by reference - m = li_boost_shared_ptr.MemberVariables() - k = li_boost_shared_ptr.Klass("smart member reference") - m.SmartMemberReference = k - val = k.getValue() - self.verifyValue("smart member reference", val) - self.verifyCount(2, k) - - kmember = m.SmartMemberReference - val = kmember.getValue() - self.verifyValue("smart member reference", val) - self.verifyCount(3, kmember) - self.verifyCount(3, k) - - # The C++ reference refers to SmartMemberValue... - kmemberVal = m.SmartMemberValue - val = kmember.getValue() - self.verifyValue("smart member reference", val) - self.verifyCount(4, kmemberVal) - self.verifyCount(4, kmember) - self.verifyCount(4, k) - - del m - self.verifyCount(3, kmemberVal) - self.verifyCount(3, kmember) - self.verifyCount(3, k) - - # plain by value - m = li_boost_shared_ptr.MemberVariables() - k = li_boost_shared_ptr.Klass("plain member value") - m.MemberValue = k - val = k.getValue() - self.verifyValue("plain member value", val) - self.verifyCount(1, k) - - kmember = m.MemberValue - val = kmember.getValue() - self.verifyValue("plain member value", val) - self.verifyCount(1, kmember) - self.verifyCount(1, k) - - del m - self.verifyCount(1, kmember) - self.verifyCount(1, k) - - # plain by pointer - m = li_boost_shared_ptr.MemberVariables() - k = li_boost_shared_ptr.Klass("plain member pointer") - m.MemberPointer = k - val = k.getValue() - self.verifyValue("plain member pointer", val) - self.verifyCount(1, k) - - kmember = m.MemberPointer - val = kmember.getValue() - self.verifyValue("plain member pointer", val) - self.verifyCount(1, kmember) - self.verifyCount(1, k) - - del m - self.verifyCount(1, kmember) - self.verifyCount(1, k) - - # plain by reference - m = li_boost_shared_ptr.MemberVariables() - k = li_boost_shared_ptr.Klass("plain member reference") - m.MemberReference = k - val = k.getValue() - self.verifyValue("plain member reference", val) - self.verifyCount(1, k) - - kmember = m.MemberReference - val = kmember.getValue() - self.verifyValue("plain member reference", val) - self.verifyCount(1, kmember) - self.verifyCount(1, k) - - del m - self.verifyCount(1, kmember) - self.verifyCount(1, k) - - # null member variables - m = li_boost_shared_ptr.MemberVariables() - - # shared_ptr by value - k = m.SmartMemberValue - if (k != None): - raise RuntimeError("expected null") - m.SmartMemberValue = None - k = m.SmartMemberValue - if (k != None): - raise RuntimeError("expected null") - self.verifyCount(0, k) - - # plain by value - try: - m.MemberValue = None - raise RuntimeError("Failed to catch null pointer") - except ValueError: - pass - - # ////////////////////////////////// Global variables //////////////////////////////////////// - # smart pointer - kglobal = li_boost_shared_ptr.cvar.GlobalSmartValue - if (kglobal != None): - raise RuntimeError("expected null") - - k = li_boost_shared_ptr.Klass("smart global value") - li_boost_shared_ptr.cvar.GlobalSmartValue = k - self.verifyCount(2, k) - - kglobal = li_boost_shared_ptr.cvar.GlobalSmartValue - val = kglobal.getValue() - self.verifyValue("smart global value", val) - self.verifyCount(3, kglobal) - self.verifyCount(3, k) - self.verifyValue("smart global value", li_boost_shared_ptr.cvar.GlobalSmartValue.getValue()) - li_boost_shared_ptr.cvar.GlobalSmartValue = None - - # plain value - k = li_boost_shared_ptr.Klass("global value") - li_boost_shared_ptr.cvar.GlobalValue = k - self.verifyCount(1, k) - - kglobal = li_boost_shared_ptr.cvar.GlobalValue - val = kglobal.getValue() - self.verifyValue("global value", val) - self.verifyCount(1, kglobal) - self.verifyCount(1, k) - self.verifyValue("global value", li_boost_shared_ptr.cvar.GlobalValue.getValue()) - - try: - li_boost_shared_ptr.cvar.GlobalValue = None - raise RuntimeError("Failed to catch null pointer") - except ValueError: - pass - - # plain pointer - kglobal = li_boost_shared_ptr.cvar.GlobalPointer - if (kglobal != None): - raise RuntimeError("expected null") - - k = li_boost_shared_ptr.Klass("global pointer") - li_boost_shared_ptr.cvar.GlobalPointer = k - self.verifyCount(1, k) - - kglobal = li_boost_shared_ptr.cvar.GlobalPointer - val = kglobal.getValue() - self.verifyValue("global pointer", val) - self.verifyCount(1, kglobal) - self.verifyCount(1, k) - li_boost_shared_ptr.cvar.GlobalPointer = None - - # plain reference - kglobal - - k = li_boost_shared_ptr.Klass("global reference") - li_boost_shared_ptr.cvar.GlobalReference = k - self.verifyCount(1, k) - - kglobal = li_boost_shared_ptr.cvar.GlobalReference - val = kglobal.getValue() - self.verifyValue("global reference", val) - self.verifyCount(1, kglobal) - self.verifyCount(1, k) - - try: - li_boost_shared_ptr.cvar.GlobalReference = None - raise RuntimeError("Failed to catch null pointer") - except ValueError: - pass - - # ////////////////////////////////// Templates //////////////////////////////////////// - pid = li_boost_shared_ptr.PairIntDouble(10, 20.2) - if (pid.baseVal1 != 20 or pid.baseVal2 != 40.4): - raise RuntimeError("Base values wrong") - if (pid.val1 != 10 or pid.val2 != 20.2): - raise RuntimeError("Derived Values wrong") - - def verifyValue(self, expected, got): - if (expected != got): - raise RuntimeError("verify value failed. Expected: ", expected, " Got: ", got) - - def verifyCount(self, expected, k): - got = li_boost_shared_ptr.use_count(k) - if (expected != got): - raise RuntimeError("verify use_count failed. Expected: ", expected, " Got: ", got) + + def main(self): + if (debug): + print "Started" + + li_boost_shared_ptr.cvar.debug_shared = debug + + # Change loop count to run for a long time to monitor memory + loopCount = 1 # 5000 + for i in range(0, loopCount): + self.runtest() + + # Expect 1 instance - the one global variable (GlobalValue) + if (li_boost_shared_ptr.Klass_getTotal_count() != 1): + raise RuntimeError("Klass.total_count=%s" % + li_boost_shared_ptr.Klass.getTotal_count()) + + wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count() + if (wrapper_count != li_boost_shared_ptr.NOT_COUNTING): + # Expect 1 instance - the one global variable (GlobalSmartValue) + if (wrapper_count != 1): + raise RuntimeError( + "shared_ptr wrapper count=%s" % wrapper_count) + + if (debug): + print "Finished" + + def runtest(self): + # simple shared_ptr usage - created in C++ + k = li_boost_shared_ptr.Klass("me oh my") + val = k.getValue() + self.verifyValue("me oh my", val) + self.verifyCount(1, k) + + # simple shared_ptr usage - not created in C++ + k = li_boost_shared_ptr.factorycreate() + val = k.getValue() + self.verifyValue("factorycreate", val) + self.verifyCount(1, k) + + # pass by shared_ptr + k = li_boost_shared_ptr.Klass("me oh my") + kret = li_boost_shared_ptr.smartpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointertest", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by shared_ptr pointer + k = li_boost_shared_ptr.Klass("me oh my") + kret = li_boost_shared_ptr.smartpointerpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointerpointertest", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by shared_ptr reference + k = li_boost_shared_ptr.Klass("me oh my") + kret = li_boost_shared_ptr.smartpointerreftest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointerreftest", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by shared_ptr pointer reference + k = li_boost_shared_ptr.Klass("me oh my") + kret = li_boost_shared_ptr.smartpointerpointerreftest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointerpointerreftest", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # const pass by shared_ptr + k = li_boost_shared_ptr.Klass("me oh my") + kret = li_boost_shared_ptr.constsmartpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # const pass by shared_ptr pointer + k = li_boost_shared_ptr.Klass("me oh my") + kret = li_boost_shared_ptr.constsmartpointerpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # const pass by shared_ptr reference + k = li_boost_shared_ptr.Klass("me oh my") + kret = li_boost_shared_ptr.constsmartpointerreftest(k) + val = kret.getValue() + self.verifyValue("me oh my", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by value + k = li_boost_shared_ptr.Klass("me oh my") + kret = li_boost_shared_ptr.valuetest(k) + val = kret.getValue() + self.verifyValue("me oh my valuetest", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # pass by pointer + k = li_boost_shared_ptr.Klass("me oh my") + kret = li_boost_shared_ptr.pointertest(k) + val = kret.getValue() + self.verifyValue("me oh my pointertest", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # pass by reference + k = li_boost_shared_ptr.Klass("me oh my") + kret = li_boost_shared_ptr.reftest(k) + val = kret.getValue() + self.verifyValue("me oh my reftest", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # pass by pointer reference + k = li_boost_shared_ptr.Klass("me oh my") + kret = li_boost_shared_ptr.pointerreftest(k) + val = kret.getValue() + self.verifyValue("me oh my pointerreftest", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # null tests + k = None + + if (li_boost_shared_ptr.smartpointertest(k) != None): + raise RuntimeError("return was not null") + + if (li_boost_shared_ptr.smartpointerpointertest(k) != None): + raise RuntimeError("return was not null") + + if (li_boost_shared_ptr.smartpointerreftest(k) != None): + raise RuntimeError("return was not null") + + if (li_boost_shared_ptr.smartpointerpointerreftest(k) != None): + raise RuntimeError("return was not null") + + if (li_boost_shared_ptr.nullsmartpointerpointertest(None) != "null pointer"): + raise RuntimeError("not null smartpointer pointer") + + try: + li_boost_shared_ptr.valuetest(k) + raise RuntimeError("Failed to catch null pointer") + except ValueError: + pass + + if (li_boost_shared_ptr.pointertest(k) != None): + raise RuntimeError("return was not null") + + try: + li_boost_shared_ptr.reftest(k) + raise RuntimeError("Failed to catch null pointer") + except ValueError: + pass + + # $owner + k = li_boost_shared_ptr.pointerownertest() + val = k.getValue() + self.verifyValue("pointerownertest", val) + self.verifyCount(1, k) + k = li_boost_shared_ptr.smartpointerpointerownertest() + val = k.getValue() + self.verifyValue("smartpointerpointerownertest", val) + self.verifyCount(1, k) + + # //////////////////////////////// Derived class ////////////////////// + # derived pass by shared_ptr + k = li_boost_shared_ptr.KlassDerived("me oh my") + kret = li_boost_shared_ptr.derivedsmartptrtest(k) + val = kret.getValue() + self.verifyValue("me oh my derivedsmartptrtest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # derived pass by shared_ptr pointer + k = li_boost_shared_ptr.KlassDerived("me oh my") + kret = li_boost_shared_ptr.derivedsmartptrpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my derivedsmartptrpointertest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # derived pass by shared_ptr ref + k = li_boost_shared_ptr.KlassDerived("me oh my") + kret = li_boost_shared_ptr.derivedsmartptrreftest(k) + val = kret.getValue() + self.verifyValue("me oh my derivedsmartptrreftest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # derived pass by shared_ptr pointer ref + k = li_boost_shared_ptr.KlassDerived("me oh my") + kret = li_boost_shared_ptr.derivedsmartptrpointerreftest(k) + val = kret.getValue() + self.verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # derived pass by pointer + k = li_boost_shared_ptr.KlassDerived("me oh my") + kret = li_boost_shared_ptr.derivedpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my derivedpointertest-Derived", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # derived pass by ref + k = li_boost_shared_ptr.KlassDerived("me oh my") + kret = li_boost_shared_ptr.derivedreftest(k) + val = kret.getValue() + self.verifyValue("me oh my derivedreftest-Derived", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # //////////////////////////////// Derived and base class mixed /////// + # pass by shared_ptr (mixed) + k = li_boost_shared_ptr.KlassDerived("me oh my") + kret = li_boost_shared_ptr.smartpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointertest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by shared_ptr pointer (mixed) + k = li_boost_shared_ptr.KlassDerived("me oh my") + kret = li_boost_shared_ptr.smartpointerpointertest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointerpointertest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by shared_ptr reference (mixed) + k = li_boost_shared_ptr.KlassDerived("me oh my") + kret = li_boost_shared_ptr.smartpointerreftest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointerreftest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by shared_ptr pointer reference (mixed) + k = li_boost_shared_ptr.KlassDerived("me oh my") + kret = li_boost_shared_ptr.smartpointerpointerreftest(k) + val = kret.getValue() + self.verifyValue("me oh my smartpointerpointerreftest-Derived", val) + self.verifyCount(2, k) + self.verifyCount(2, kret) + + # pass by value (mixed) + k = li_boost_shared_ptr.KlassDerived("me oh my") + kret = li_boost_shared_ptr.valuetest(k) + val = kret.getValue() + self.verifyValue("me oh my valuetest", val) # note slicing + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # pass by pointer (mixed) + k = li_boost_shared_ptr.KlassDerived("me oh my") + kret = li_boost_shared_ptr.pointertest(k) + val = kret.getValue() + self.verifyValue("me oh my pointertest-Derived", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # pass by ref (mixed) + k = li_boost_shared_ptr.KlassDerived("me oh my") + kret = li_boost_shared_ptr.reftest(k) + val = kret.getValue() + self.verifyValue("me oh my reftest-Derived", val) + self.verifyCount(1, k) + self.verifyCount(1, kret) + + # //////////////////////////////// Overloading tests ////////////////// + # Base class + k = li_boost_shared_ptr.Klass("me oh my") + self.verifyValue(li_boost_shared_ptr.overload_rawbyval(k), "rawbyval") + self.verifyValue(li_boost_shared_ptr.overload_rawbyref(k), "rawbyref") + self.verifyValue(li_boost_shared_ptr.overload_rawbyptr(k), "rawbyptr") + self.verifyValue( + li_boost_shared_ptr.overload_rawbyptrref(k), "rawbyptrref") + + self.verifyValue( + li_boost_shared_ptr.overload_smartbyval(k), "smartbyval") + self.verifyValue( + li_boost_shared_ptr.overload_smartbyref(k), "smartbyref") + self.verifyValue( + li_boost_shared_ptr.overload_smartbyptr(k), "smartbyptr") + self.verifyValue( + li_boost_shared_ptr.overload_smartbyptrref(k), "smartbyptrref") + + # Derived class + k = li_boost_shared_ptr.KlassDerived("me oh my") + self.verifyValue(li_boost_shared_ptr.overload_rawbyval(k), "rawbyval") + self.verifyValue(li_boost_shared_ptr.overload_rawbyref(k), "rawbyref") + self.verifyValue(li_boost_shared_ptr.overload_rawbyptr(k), "rawbyptr") + self.verifyValue( + li_boost_shared_ptr.overload_rawbyptrref(k), "rawbyptrref") + + self.verifyValue( + li_boost_shared_ptr.overload_smartbyval(k), "smartbyval") + self.verifyValue( + li_boost_shared_ptr.overload_smartbyref(k), "smartbyref") + self.verifyValue( + li_boost_shared_ptr.overload_smartbyptr(k), "smartbyptr") + self.verifyValue( + li_boost_shared_ptr.overload_smartbyptrref(k), "smartbyptrref") + + # 3rd derived class + k = li_boost_shared_ptr.Klass3rdDerived("me oh my") + val = k.getValue() + self.verifyValue("me oh my-3rdDerived", val) + self.verifyCount(1, k) + val = li_boost_shared_ptr.test3rdupcast(k) + self.verifyValue("me oh my-3rdDerived", val) + self.verifyCount(1, k) + + # //////////////////////////////// Member variables /////////////////// + # smart pointer by value + m = li_boost_shared_ptr.MemberVariables() + k = li_boost_shared_ptr.Klass("smart member value") + m.SmartMemberValue = k + val = k.getValue() + self.verifyValue("smart member value", val) + self.verifyCount(2, k) + + kmember = m.SmartMemberValue + val = kmember.getValue() + self.verifyValue("smart member value", val) + self.verifyCount(3, kmember) + self.verifyCount(3, k) + + del m + self.verifyCount(2, kmember) + self.verifyCount(2, k) + + # smart pointer by pointer + m = li_boost_shared_ptr.MemberVariables() + k = li_boost_shared_ptr.Klass("smart member pointer") + m.SmartMemberPointer = k + val = k.getValue() + self.verifyValue("smart member pointer", val) + self.verifyCount(1, k) + + kmember = m.SmartMemberPointer + val = kmember.getValue() + self.verifyValue("smart member pointer", val) + self.verifyCount(2, kmember) + self.verifyCount(2, k) + + del m + self.verifyCount(2, kmember) + self.verifyCount(2, k) + + # smart pointer by reference + m = li_boost_shared_ptr.MemberVariables() + k = li_boost_shared_ptr.Klass("smart member reference") + m.SmartMemberReference = k + val = k.getValue() + self.verifyValue("smart member reference", val) + self.verifyCount(2, k) + + kmember = m.SmartMemberReference + val = kmember.getValue() + self.verifyValue("smart member reference", val) + self.verifyCount(3, kmember) + self.verifyCount(3, k) + + # The C++ reference refers to SmartMemberValue... + kmemberVal = m.SmartMemberValue + val = kmember.getValue() + self.verifyValue("smart member reference", val) + self.verifyCount(4, kmemberVal) + self.verifyCount(4, kmember) + self.verifyCount(4, k) + + del m + self.verifyCount(3, kmemberVal) + self.verifyCount(3, kmember) + self.verifyCount(3, k) + + # plain by value + m = li_boost_shared_ptr.MemberVariables() + k = li_boost_shared_ptr.Klass("plain member value") + m.MemberValue = k + val = k.getValue() + self.verifyValue("plain member value", val) + self.verifyCount(1, k) + + kmember = m.MemberValue + val = kmember.getValue() + self.verifyValue("plain member value", val) + self.verifyCount(1, kmember) + self.verifyCount(1, k) + + del m + self.verifyCount(1, kmember) + self.verifyCount(1, k) + + # plain by pointer + m = li_boost_shared_ptr.MemberVariables() + k = li_boost_shared_ptr.Klass("plain member pointer") + m.MemberPointer = k + val = k.getValue() + self.verifyValue("plain member pointer", val) + self.verifyCount(1, k) + + kmember = m.MemberPointer + val = kmember.getValue() + self.verifyValue("plain member pointer", val) + self.verifyCount(1, kmember) + self.verifyCount(1, k) + + del m + self.verifyCount(1, kmember) + self.verifyCount(1, k) + + # plain by reference + m = li_boost_shared_ptr.MemberVariables() + k = li_boost_shared_ptr.Klass("plain member reference") + m.MemberReference = k + val = k.getValue() + self.verifyValue("plain member reference", val) + self.verifyCount(1, k) + + kmember = m.MemberReference + val = kmember.getValue() + self.verifyValue("plain member reference", val) + self.verifyCount(1, kmember) + self.verifyCount(1, k) + + del m + self.verifyCount(1, kmember) + self.verifyCount(1, k) + + # null member variables + m = li_boost_shared_ptr.MemberVariables() + + # shared_ptr by value + k = m.SmartMemberValue + if (k != None): + raise RuntimeError("expected null") + m.SmartMemberValue = None + k = m.SmartMemberValue + if (k != None): + raise RuntimeError("expected null") + self.verifyCount(0, k) + + # plain by value + try: + m.MemberValue = None + raise RuntimeError("Failed to catch null pointer") + except ValueError: + pass + + # ////////////////////////////////// Global variables ///////////////// + # smart pointer + kglobal = li_boost_shared_ptr.cvar.GlobalSmartValue + if (kglobal != None): + raise RuntimeError("expected null") + + k = li_boost_shared_ptr.Klass("smart global value") + li_boost_shared_ptr.cvar.GlobalSmartValue = k + self.verifyCount(2, k) + + kglobal = li_boost_shared_ptr.cvar.GlobalSmartValue + val = kglobal.getValue() + self.verifyValue("smart global value", val) + self.verifyCount(3, kglobal) + self.verifyCount(3, k) + self.verifyValue( + "smart global value", li_boost_shared_ptr.cvar.GlobalSmartValue.getValue()) + li_boost_shared_ptr.cvar.GlobalSmartValue = None + + # plain value + k = li_boost_shared_ptr.Klass("global value") + li_boost_shared_ptr.cvar.GlobalValue = k + self.verifyCount(1, k) + + kglobal = li_boost_shared_ptr.cvar.GlobalValue + val = kglobal.getValue() + self.verifyValue("global value", val) + self.verifyCount(1, kglobal) + self.verifyCount(1, k) + self.verifyValue( + "global value", li_boost_shared_ptr.cvar.GlobalValue.getValue()) + + try: + li_boost_shared_ptr.cvar.GlobalValue = None + raise RuntimeError("Failed to catch null pointer") + except ValueError: + pass + + # plain pointer + kglobal = li_boost_shared_ptr.cvar.GlobalPointer + if (kglobal != None): + raise RuntimeError("expected null") + + k = li_boost_shared_ptr.Klass("global pointer") + li_boost_shared_ptr.cvar.GlobalPointer = k + self.verifyCount(1, k) + + kglobal = li_boost_shared_ptr.cvar.GlobalPointer + val = kglobal.getValue() + self.verifyValue("global pointer", val) + self.verifyCount(1, kglobal) + self.verifyCount(1, k) + li_boost_shared_ptr.cvar.GlobalPointer = None + + # plain reference + kglobal + + k = li_boost_shared_ptr.Klass("global reference") + li_boost_shared_ptr.cvar.GlobalReference = k + self.verifyCount(1, k) + + kglobal = li_boost_shared_ptr.cvar.GlobalReference + val = kglobal.getValue() + self.verifyValue("global reference", val) + self.verifyCount(1, kglobal) + self.verifyCount(1, k) + + try: + li_boost_shared_ptr.cvar.GlobalReference = None + raise RuntimeError("Failed to catch null pointer") + except ValueError: + pass + + # ////////////////////////////////// Templates //////////////////////// + pid = li_boost_shared_ptr.PairIntDouble(10, 20.2) + if (pid.baseVal1 != 20 or pid.baseVal2 != 40.4): + raise RuntimeError("Base values wrong") + if (pid.val1 != 10 or pid.val2 != 20.2): + raise RuntimeError("Derived Values wrong") + + def verifyValue(self, expected, got): + if (expected != got): + raise RuntimeError( + "verify value failed. Expected: ", expected, " Got: ", got) + + def verifyCount(self, expected, k): + got = li_boost_shared_ptr.use_count(k) + if (expected != got): + raise RuntimeError( + "verify use_count failed. Expected: ", expected, " Got: ", got) runme = li_boost_shared_ptr_runme() runme.main() - diff --git a/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py index c10627f36..6b56ec479 100644 --- a/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py +++ b/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py @@ -3,28 +3,28 @@ from li_boost_shared_ptr_template import * b = BaseINTEGER() d = DerivedINTEGER() if b.bar() != 1: - raise RuntimeError + raise RuntimeError if d.bar() != 2: - raise RuntimeError + raise RuntimeError if bar_getter(b) != 1: - raise RuntimeError + raise RuntimeError # Fix reverted in rev 12953 -#if bar_getter(d) != 2: +# if bar_getter(d) != 2: # raise RuntimeError b = BaseDefaultInt() d = DerivedDefaultInt() d2 = DerivedDefaultInt2() if b.bar2() != 3: - raise RuntimeError + raise RuntimeError if d.bar2() != 4: - raise RuntimeError + raise RuntimeError if d2.bar2() != 4: - raise RuntimeError + raise RuntimeError if bar2_getter(b) != 3: - raise RuntimeError + raise RuntimeError # Fix reverted in rev 12953 -#if bar2_getter(d) != 4: +# if bar2_getter(d) != 4: # raise RuntimeError -#if bar2_getter(d2) != 4: +# if bar2_getter(d2) != 4: # raise RuntimeError diff --git a/Examples/test-suite/python/li_cdata_runme.py b/Examples/test-suite/python/li_cdata_runme.py index 061ca6f68..8a132e7dd 100644 --- a/Examples/test-suite/python/li_cdata_runme.py +++ b/Examples/test-suite/python/li_cdata_runme.py @@ -6,5 +6,4 @@ m = malloc(256) memmove(m, s) ss = cdata(m, 7) if ss != "ABC abc": - raise "failed" - + raise "failed" diff --git a/Examples/test-suite/python/li_cpointer_runme.py b/Examples/test-suite/python/li_cpointer_runme.py index ac95ff4b9..1565069cf 100644 --- a/Examples/test-suite/python/li_cpointer_runme.py +++ b/Examples/test-suite/python/li_cpointer_runme.py @@ -2,7 +2,7 @@ from li_cpointer import * p = new_intp() -intp_assign(p,3) +intp_assign(p, 3) if intp_value(p) != 3: raise RuntimeError diff --git a/Examples/test-suite/python/li_cstring_runme.py b/Examples/test-suite/python/li_cstring_runme.py index 6503744bd..55b51d1c7 100644 --- a/Examples/test-suite/python/li_cstring_runme.py +++ b/Examples/test-suite/python/li_cstring_runme.py @@ -2,7 +2,7 @@ from li_cstring import * if count("ab\0ab\0ab\0", 0) != 3: - raise RuntimeError + raise RuntimeError if test1() != "Hello World": raise RuntimeError @@ -17,16 +17,15 @@ if test3("hello") != "hello-suffix": if test4("hello") != "hello-suffix": print test4("hello") raise RuntimeError - + if test5(4) != 'xxxx': raise RuntimeError if test6(10) != 'xxxxx': raise RuntimeError - -if test7() !="Hello world!": + +if test7() != "Hello world!": raise RuntimeError if test8() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_": raise RuntimeError - diff --git a/Examples/test-suite/python/li_cwstring_runme.py b/Examples/test-suite/python/li_cwstring_runme.py index 4ab590882..aaa5b6e62 100644 --- a/Examples/test-suite/python/li_cwstring_runme.py +++ b/Examples/test-suite/python/li_cwstring_runme.py @@ -1,7 +1,7 @@ from li_cwstring import * if count(u"ab\0ab\0ab\0", 0) != 3: - raise RuntimeError + raise RuntimeError if test1() != u"Hello World": raise RuntimeError @@ -14,16 +14,15 @@ if test3("hello") != u"hello-suffix": if test4("hello") != u"hello-suffix": raise RuntimeError - + if test5(4) != u'xxxx': raise RuntimeError if test6(10) != u'xxxxx': raise RuntimeError - + if test7() != u"Hello world!": raise RuntimeError if test8() != u" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_": raise RuntimeError - diff --git a/Examples/test-suite/python/li_implicit_runme.py b/Examples/test-suite/python/li_implicit_runme.py index a0672e016..d8dd0fdcc 100644 --- a/Examples/test-suite/python/li_implicit_runme.py +++ b/Examples/test-suite/python/li_implicit_runme.py @@ -9,9 +9,8 @@ ad, get(ad) ab, get(ab) if get(ai) != get(1): - raise RuntimeError,"bad implicit type" + raise RuntimeError, "bad implicit type" if get(ad) != get(2.0): - raise RuntimeError,"bad implicit type" + raise RuntimeError, "bad implicit type" if get(ab) != get(b): - raise RuntimeError,"bad implicit type" - + raise RuntimeError, "bad implicit type" diff --git a/Examples/test-suite/python/li_std_auto_ptr_runme.py b/Examples/test-suite/python/li_std_auto_ptr_runme.py index d82a89f42..6d2479f87 100644 --- a/Examples/test-suite/python/li_std_auto_ptr_runme.py +++ b/Examples/test-suite/python/li_std_auto_ptr_runme.py @@ -3,15 +3,15 @@ from li_std_auto_ptr import * k1 = makeKlassAutoPtr("first") k2 = makeKlassAutoPtr("second") if Klass_getTotal_count() != 2: - raise "number of objects should be 2" + raise "number of objects should be 2" del k1 if Klass_getTotal_count() != 1: - raise "number of objects should be 1" + raise "number of objects should be 1" if k2.getLabel() != "second": - raise "wrong object label" + raise "wrong object label" del k2 if Klass_getTotal_count() != 0: - raise "no objects should be left" + raise "no objects should be left" diff --git a/Examples/test-suite/python/li_std_carray_runme.py b/Examples/test-suite/python/li_std_carray_runme.py index 803bc96c5..36eeaf173 100644 --- a/Examples/test-suite/python/li_std_carray_runme.py +++ b/Examples/test-suite/python/li_std_carray_runme.py @@ -2,7 +2,7 @@ from li_std_carray import * v3 = Vector3() -for i in range(0,len(v3)): +for i in range(0, len(v3)): v3[i] = i i = 0 @@ -14,9 +14,9 @@ for d in v3: m3 = Matrix3() -for i in range(0,len(m3)): +for i in range(0, len(m3)): v3 = m3[i] - for j in range(0,len(v3)): + for j in range(0, len(v3)): v3[j] = i + j i = 0 @@ -30,12 +30,10 @@ for v3 in m3: i = i + 1 pass -for i in range(0,len(m3)): - for j in range(0,len(m3)): +for i in range(0, len(m3)): + for j in range(0, len(m3)): if m3[i][j] != i + j: raise RuntimeError -da = Vector3((1,2,3)) -ma = Matrix3(((1,2,3),(4,5,6),(7,8,9))) - - +da = Vector3((1, 2, 3)) +ma = Matrix3(((1, 2, 3), (4, 5, 6), (7, 8, 9))) diff --git a/Examples/test-suite/python/li_std_containers_int_runme.py b/Examples/test-suite/python/li_std_containers_int_runme.py index 3cbbb2862..c7d262f60 100644 --- a/Examples/test-suite/python/li_std_containers_int_runme.py +++ b/Examples/test-suite/python/li_std_containers_int_runme.py @@ -1,158 +1,170 @@ -# Check std::vector and std::list behaves the same as Python iterable types (list) +# Check std::vector and std::list behaves the same as Python iterable +# types (list) from li_std_containers_int import * 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): - if len(a) != len(b): - failed(a, b, "different sizes") - for i in range(len(a)): - if a[i] != b[i]: - failed(a, b, "elements are different") + if len(a) != len(b): + failed(a, b, "different sizes") + for i in range(len(a)): + if a[i] != b[i]: + failed(a, b, "elements are different") + def compare_containers(pythonlist, swigvector, swiglist): - compare_sequences(pythonlist, swigvector) - compare_sequences(pythonlist, swiglist) + compare_sequences(pythonlist, swigvector) + compare_sequences(pythonlist, swiglist) + +# Check std::vector and std::list assignment behaves same as Python list +# assignment including exceptions + -# Check std::vector and std::list assignment behaves same as Python list assignment including exceptions def container_insert_step(i, j, step, newval): - ps = range(6) - iv = vector_int(ps) - il = list_int(ps) + ps = range(6) + iv = vector_int(ps) + il = list_int(ps) - # Python slice - try: - if step == None: - if j == None: - ps[i] = newval - else: - ps[i:j] = newval - else: - if j == None: - ps[i::step] = newval - else: - ps[i:j:step] = newval - ps_error = None - except ValueError, e: - ps_error = e - except IndexError, e: - ps_error = e + # Python slice + try: + if step == None: + if j == None: + ps[i] = newval + else: + ps[i:j] = newval + else: + if j == None: + ps[i::step] = newval + else: + ps[i:j:step] = newval + ps_error = None + except ValueError, e: + ps_error = e + except IndexError, e: + ps_error = e - # std::vector - try: - if step == None: - if j == None: - iv[i] = newval - else: - iv[i:j] = newval - else: - if j == None: - iv[i::step] = newval - else: - iv[i:j:step] = newval - iv_error = None - except ValueError, e: - iv_error = e - except IndexError, e: - iv_error = e + # std::vector + try: + if step == None: + if j == None: + iv[i] = newval + else: + iv[i:j] = newval + else: + if j == None: + iv[i::step] = newval + else: + iv[i:j:step] = newval + iv_error = None + except ValueError, e: + iv_error = e + except IndexError, e: + iv_error = e - # std::list - try: - if step == None: - if j == None: - il[i] = newval - else: - il[i:j] = newval - else: - if j == None: - il[i::step] = newval - else: - il[i:j:step] = newval - il_error = None - except ValueError, e: - il_error = e - except IndexError, e: - il_error = e + # std::list + try: + if step == None: + if j == None: + il[i] = newval + else: + il[i:j] = newval + else: + if j == None: + il[i::step] = newval + else: + il[i:j:step] = newval + il_error = None + except ValueError, e: + il_error = e + except IndexError, e: + il_error = e + + # Python 2.6 contains bug fixes in extended slicing syntax: + # http://docs.python.org/2/whatsnew/2.6.html + skip_check = ps_error != None and( + iv_error == il_error == None) and step > 0 and (sys.version_info[0:2] < (2, 6)) + if not(skip_check): + if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))): + raise RuntimeError, "ValueError exception not consistently thrown: " + \ + str(ps_error) + " " + str(iv_error) + " " + str(il_error) + + compare_containers(ps, iv, il) + + +# Check std::vector and std::list delete behaves same as Python list +# delete including exceptions +def container_delete_step(i, j, step): + ps = range(6) + iv = vector_int(ps) + il = list_int(ps) + + # Python slice + try: + if step == None: + if j == None: + del ps[i] + else: + del ps[i:j] + else: + if j == None: + del ps[i::step] + else: + del ps[i:j:step] + ps_error = None + except ValueError, e: + ps_error = e + except IndexError, e: + ps_error = e + + # std::vector + try: + if step == None: + if j == None: + del iv[i] + else: + del iv[i:j] + else: + if j == None: + del iv[i::step] + else: + del iv[i:j:step] + iv_error = None + except ValueError, e: + iv_error = e + except IndexError, e: + iv_error = e + + # std::list + try: + if step == None: + if j == None: + del il[i] + else: + del il[i:j] + else: + if j == None: + del il[i::step] + else: + del il[i:j:step] + il_error = None + except ValueError, e: + il_error = e + except IndexError, e: + il_error = e - # Python 2.6 contains bug fixes in extended slicing syntax: http://docs.python.org/2/whatsnew/2.6.html - skip_check = ps_error != None and(iv_error == il_error == None) and step > 0 and (sys.version_info[0:2] < (2, 6)) - if not(skip_check): if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))): - raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error) + raise RuntimeError, "ValueError exception not consistently thrown: " + \ + str(ps_error) + " " + str(iv_error) + " " + str(il_error) compare_containers(ps, iv, il) -# Check std::vector and std::list delete behaves same as Python list delete including exceptions -def container_delete_step(i, j, step): - ps = range(6) - iv = vector_int(ps) - il = list_int(ps) - - # Python slice - try: - if step == None: - if j == None: - del ps[i] - else: - del ps[i:j] - else: - if j == None: - del ps[i::step] - else: - del ps[i:j:step] - ps_error = None - except ValueError, e: - ps_error = e - except IndexError, e: - ps_error = e - - # std::vector - try: - if step == None: - if j == None: - del iv[i] - else: - del iv[i:j] - else: - if j == None: - del iv[i::step] - else: - del iv[i:j:step] - iv_error = None - except ValueError, e: - iv_error = e - except IndexError, e: - iv_error = e - - # std::list - try: - if step == None: - if j == None: - del il[i] - else: - del il[i:j] - else: - if j == None: - del il[i::step] - else: - del il[i:j:step] - il_error = None - except ValueError, e: - il_error = e - except IndexError, e: - il_error = e - - if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))): - raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error) - - compare_containers(ps, iv, il) - - -ps = [0,1,2,3,4,5] +ps = [0, 1, 2, 3, 4, 5] iv = vector_int(ps) il = list_int(ps) @@ -164,7 +176,7 @@ compare_containers(ps[1:3], iv[1:3], il[1:3]) compare_containers(ps[2:4], iv[2:4], il[2:4]) compare_containers(ps[0:3], iv[0:3], il[0:3]) compare_containers(ps[3:6], iv[3:6], il[3:6]) -compare_containers(ps[3:10], iv[3:10], il[3:10]) # beyond end of range +compare_containers(ps[3:10], iv[3:10], il[3:10]) # beyond end of range # before beginning of range (negative indexing) compare_containers(ps[-1:7], iv[-1:7], il[-1:7]) @@ -172,7 +184,8 @@ compare_containers(ps[-2:7], iv[-2:7], il[-2:7]) compare_containers(ps[-5:7], iv[-5:7], il[-5:7]) compare_containers(ps[-6:7], iv[-6:7], il[-6:7]) -# before beginning of range (negative indexing, negative index is > container size) +# before beginning of range (negative indexing, negative index is > +# container size) compare_containers(ps[-7:7], iv[-7:7], il[-7:7]) compare_containers(ps[-100:7], iv[-100:7], il[-100:7]) @@ -222,48 +235,52 @@ compare_containers(ps[::-5], iv[::-5], il[::-5]) # insert sequences (growing, shrinking and staying same size) for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]: - # single element set/replace - container_insert_step(start, None, None, 111) - for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]: - container_insert_step(start, end, None, [111, 222, 333, 444, 555, 666, 777]) - container_insert_step(start, end, None, [111, 222, 333, 444, 555, 666]) - container_insert_step(start, end, None, [111, 222, 333, 444, 555]) - container_insert_step(start, end, None, [111, 222, 333, 444]) - container_insert_step(start, end, None, [111, 222, 333]) - container_insert_step(start, end, None, [111, 222]) - container_insert_step(start, end, None, [111]) - container_insert_step(start, end, None, []) + # single element set/replace + container_insert_step(start, None, None, 111) + for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]: + container_insert_step( + start, end, None, [111, 222, 333, 444, 555, 666, 777]) + container_insert_step(start, end, None, [111, 222, 333, 444, 555, 666]) + container_insert_step(start, end, None, [111, 222, 333, 444, 555]) + container_insert_step(start, end, None, [111, 222, 333, 444]) + container_insert_step(start, end, None, [111, 222, 333]) + container_insert_step(start, end, None, [111, 222]) + container_insert_step(start, end, None, [111]) + container_insert_step(start, end, None, []) # delete sequences (growing, shrinking and staying same size) for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]: - # single element delete - container_delete_step(start, None, None) - for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]: - container_delete_step(start, end, None) - for step in range(-7,7): - container_delete_step(start, end, step) + # single element delete + container_delete_step(start, None, None) + for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]: + container_delete_step(start, end, None) + for step in range(-7, 7): + container_delete_step(start, end, step) ps = range(6) iv = vector_int(ps) il = list_int(ps) -del ps[:]; del iv[:]; del il[:] +del ps[:] +del iv[:] +del il[:] compare_containers(ps, iv, il) for end in range(7): - for step in range(-7,7): - for start in range(7): - container_insert_step(start, end, step, [111, 222, 333, 444, 555, 666, 777]) - container_insert_step(start, end, step, [111, 222, 333, 444, 555, 666]) - container_insert_step(start, end, step, [111, 222, 333, 444, 555]) - container_insert_step(start, end, step, [111, 222, 333, 444]) - container_insert_step(start, end, step, [111, 222, 333]) - container_insert_step(start, end, step, [111, 222]) - container_insert_step(start, end, step, [111]) - container_insert_step(start, end, step, []) + for step in range(-7, 7): + for start in range(7): + container_insert_step( + start, end, step, [111, 222, 333, 444, 555, 666, 777]) + container_insert_step( + start, end, step, [111, 222, 333, 444, 555, 666]) + container_insert_step(start, end, step, [111, 222, 333, 444, 555]) + container_insert_step(start, end, step, [111, 222, 333, 444]) + container_insert_step(start, end, step, [111, 222, 333]) + container_insert_step(start, end, step, [111, 222]) + container_insert_step(start, end, step, [111]) + container_insert_step(start, end, step, []) try: - x = iv[::0] - raise RuntimeError("Zero step not caught") + x = iv[::0] + raise RuntimeError("Zero step not caught") except ValueError: - pass - + pass 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 a86e7a562..36abb33f4 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 @@ -3,17 +3,29 @@ from li_std_except_as_class import * # 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 + 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 + # 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_map_member_runme.py b/Examples/test-suite/python/li_std_map_member_runme.py index 8b5877dae..d20442472 100644 --- a/Examples/test-suite/python/li_std_map_member_runme.py +++ b/Examples/test-suite/python/li_std_map_member_runme.py @@ -3,9 +3,9 @@ import li_std_map_member a = li_std_map_member.mapita() a[1] = li_std_map_member.TestA() -if (a[1].i != 1) : +if (a[1].i != 1): raise RuntimeError("a[1] != 1") a[1].i = 2 -if (a[1].i != 2) : +if (a[1].i != 2): raise RuntimeError("a[1] != 2") diff --git a/Examples/test-suite/python/li_std_map_runme.py b/Examples/test-suite/python/li_std_map_runme.py index ae75bdda0..af3e1d989 100644 --- a/Examples/test-suite/python/li_std_map_runme.py +++ b/Examples/test-suite/python/li_std_map_runme.py @@ -4,8 +4,8 @@ a1 = li_std_map.A(3) a2 = li_std_map.A(7) -p0 = li_std_map.pairii(1,2) -p1 = li_std_map.pairA(1,a1.this) +p0 = li_std_map.pairii(1, 2) +p1 = li_std_map.pairA(1, a1.this) m = {} m[1] = a1 m[2] = a2 @@ -14,38 +14,33 @@ pp1 = li_std_map.p_identa(p1) mm = li_std_map.m_identa(m) - m = li_std_map.mapA() m[1] = a1 m[2] = a2 -pm ={} +pm = {} for k in m: - pm[k] = m[k] - -for k in m: - if pm[k].this != m[k].this: - print pm[k], m[k] - raise RuntimeError - - + pm[k] = m[k] +for k in m: + if pm[k].this != m[k].this: + print pm[k], m[k] + raise RuntimeError m = {} -m[1] = (1,2) +m[1] = (1, 2) m["foo"] = "hello" pm = li_std_map.pymap() -for k in m: - pm[k] = m[k] - -for k in pm: - if (pm[k] != m[k]): - raise RuntimeError +for k in m: + pm[k] = m[k] +for k in pm: + if (pm[k] != m[k]): + raise RuntimeError mii = li_std_map.IntIntMap() @@ -54,5 +49,4 @@ mii[1] = 1 mii[1] = 2 if mii[1] != 2: - raise RuntimeError - + raise RuntimeError diff --git a/Examples/test-suite/python/li_std_pair_extra_runme.py b/Examples/test-suite/python/li_std_pair_extra_runme.py index dc6e31b76..f26badf08 100644 --- a/Examples/test-suite/python/li_std_pair_extra_runme.py +++ b/Examples/test-suite/python/li_std_pair_extra_runme.py @@ -1,59 +1,58 @@ import li_std_pair_extra -p = (1,2) +p = (1, 2) p1 = li_std_pair_extra.p_inout(p) p2 = li_std_pair_extra.p_inoutd(p1) d1 = li_std_pair_extra.d_inout(2) -i,d2 = li_std_pair_extra.d_inout2(2) +i, d2 = li_std_pair_extra.d_inout2(2) -i,p = li_std_pair_extra.p_inout2(p) -p3,p4 = li_std_pair_extra.p_inout3(p1,p1) +i, p = li_std_pair_extra.p_inout2(p) +p3, p4 = li_std_pair_extra.p_inout3(p1, p1) -psi = li_std_pair_extra.SIPair("hello",1) -pci = li_std_pair_extra.CIPair(1,1) +psi = li_std_pair_extra.SIPair("hello", 1) +pci = li_std_pair_extra.CIPair(1, 1) #psi.first = "hi" -psi = li_std_pair_extra.SIPair("hi",1) -if psi != ("hi",1): - raise RuntimeError +psi = li_std_pair_extra.SIPair("hi", 1) +if psi != ("hi", 1): + raise RuntimeError -psii = li_std_pair_extra.SIIPair(psi,1) +psii = li_std_pair_extra.SIIPair(psi, 1) a = li_std_pair_extra.A() b = li_std_pair_extra.B() -pab = li_std_pair_extra.ABPair(a,b); +pab = li_std_pair_extra.ABPair(a, b) pab.first = a pab.first.val = 2 if pab.first.val != 2: - raise RuntimeError - + raise RuntimeError -pci = li_std_pair_extra.CIntPair(1,0) + +pci = li_std_pair_extra.CIntPair(1, 0) a = li_std_pair_extra.A(5) -p1 = li_std_pair_extra.pairP1(1,a.this) -p2 = li_std_pair_extra.pairP2(a,1) -p3 = li_std_pair_extra.pairP3(a,a) +p1 = li_std_pair_extra.pairP1(1, a.this) +p2 = li_std_pair_extra.pairP2(a, 1) +p3 = li_std_pair_extra.pairP3(a, a) if a.val != li_std_pair_extra.p_identa(p1.this)[1].val: - raise RuntimeError - -p = li_std_pair_extra.IntPair(1,10) + raise RuntimeError + +p = li_std_pair_extra.IntPair(1, 10) p.first = 1 -p = li_std_pair_extra.paircA1(1,a) +p = li_std_pair_extra.paircA1(1, a) p.first p.second -p = li_std_pair_extra.paircA2(1,a) -pp = li_std_pair_extra.pairiiA(1,p) - +p = li_std_pair_extra.paircA2(1, a) +pp = li_std_pair_extra.pairiiA(1, p) diff --git a/Examples/test-suite/python/li_std_pair_using_runme.py b/Examples/test-suite/python/li_std_pair_using_runme.py index a8b261035..18f962235 100644 --- a/Examples/test-suite/python/li_std_pair_using_runme.py +++ b/Examples/test-suite/python/li_std_pair_using_runme.py @@ -6,5 +6,4 @@ two_tuple = ("two", 2) two = StringIntPair(two_tuple) if bounce(one) != one_tuple: - raise RuntimeError - + raise RuntimeError diff --git a/Examples/test-suite/python/li_std_set_runme.py b/Examples/test-suite/python/li_std_set_runme.py index 449333e73..ad3c6d881 100644 --- a/Examples/test-suite/python/li_std_set_runme.py +++ b/Examples/test-suite/python/li_std_set_runme.py @@ -25,7 +25,7 @@ if i.next() != "c": b = s.begin() e = s.end() sum = "" -while (b != e): +while (b != e): sum = sum + b.next() if sum != "abc": raise RuntimeError @@ -33,14 +33,13 @@ if sum != "abc": b = s.rbegin() e = s.rend() sum = "" -while (b != e): - sum = sum + b.next() +while (b != e): + sum = sum + b.next() if sum != "cba": raise RuntimeError - si = set_int() si.append(1) @@ -56,8 +55,6 @@ if i.next() != 3: raise RuntimeError - - i = s.begin() i.next() s.erase(i) @@ -65,7 +62,7 @@ s.erase(i) b = s.begin() e = s.end() sum = "" -while (b != e): +while (b != e): sum = sum + b.next() if sum != "ac": raise RuntimeError @@ -75,22 +72,21 @@ b = s.begin() e = s.end() if e - b != 2: raise RuntimeError - + m = b + 1 if m.value() != "c": raise RuntimeError - s = pyset() -s.insert((1,2)) +s.insert((1, 2)) s.insert(1) s.insert("hello") sum = () for i in s: - sum = sum + (i,) + sum = sum + (i,) -if (len(sum) != 3 or (not 1 in sum) or (not 'hello' in sum) or (not (1, 2) in sum)) : +if (len(sum) != 3 or (not 1 in sum) or (not 'hello' in sum) or (not (1, 2) in sum)): raise RuntimeError diff --git a/Examples/test-suite/python/li_std_stream_runme.py b/Examples/test-suite/python/li_std_stream_runme.py index d41e41f4a..08c308856 100644 --- a/Examples/test-suite/python/li_std_stream_runme.py +++ b/Examples/test-suite/python/li_std_stream_runme.py @@ -1,7 +1,6 @@ from li_std_stream import * - a = A() o = ostringstream() @@ -9,6 +8,6 @@ o = ostringstream() o << a << " " << 2345 << " " << 1.435 -if o.str() != "A class 2345 1.435": - print "\"%s\"" % (o.str(),) - raise RuntimeError +if o.str() != "A class 2345 1.435": + print "\"%s\"" % (o.str(),) + raise RuntimeError 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 503d09eb5..b65f0774a 100644 --- a/Examples/test-suite/python/li_std_string_extra_runme.py +++ b/Examples/test-suite/python/li_std_string_extra_runme.py @@ -1,135 +1,134 @@ import li_std_string_extra -x="hello" - +x = "hello" if li_std_string_extra.test_ccvalue(x) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError, "bad string mapping" if li_std_string_extra.test_cvalue(x) != x: - raise RuntimeError, "bad string mapping" + 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" + print x, li_std_string_extra.test_value(x) + raise RuntimeError, "bad string mapping" if li_std_string_extra.test_const_reference(x) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError, "bad string mapping" s = li_std_string_extra.string("he") #s += "ll" -#s.append('o') +# s.append('o') s = s + "llo" if s != x: - print s, x - raise RuntimeError, "bad string mapping" + print s, x + raise RuntimeError, "bad string mapping" if s[1:4] != x[1:4]: - raise RuntimeError, "bad string mapping" + raise RuntimeError, "bad string mapping" if li_std_string_extra.test_value(s) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError, "bad string mapping" if li_std_string_extra.test_const_reference(s) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError, "bad string mapping" a = li_std_string_extra.A(s) if li_std_string_extra.test_value(a) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError, "bad string mapping" if li_std_string_extra.test_const_reference(a) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError, "bad string mapping" b = li_std_string_extra.string(" world") s = a + b if a + b != "hello world": - print a + b - raise RuntimeError, "bad string mapping" - + print a + b + raise RuntimeError, "bad string mapping" + if a + " world" != "hello world": - raise RuntimeError, "bad string mapping" + raise RuntimeError, "bad string mapping" # This is expected to fail with -builtin option # Reverse operators not supported in builtin types if not li_std_string_extra.is_python_builtin(): - if "hello" + b != "hello world": - raise RuntimeError, "bad string mapping" + 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" - c = "hello" + b - if c.find_last_of("l") != 9: - raise RuntimeError, "bad string mapping" - s = "hello world" b = li_std_string_extra.B("hi") b.name = li_std_string_extra.string("hello") if b.name != "hello": - raise RuntimeError, "bad string mapping" + raise RuntimeError, "bad string mapping" b.a = li_std_string_extra.A("hello") if b.a != "hello": - raise RuntimeError, "bad string mapping" + raise RuntimeError, "bad string mapping" if li_std_string_extra.test_value_basic1(x) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError, "bad string mapping" if li_std_string_extra.test_value_basic2(x) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError, "bad string mapping" if li_std_string_extra.test_value_basic3(x) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError, "bad string mapping" # Global variables s = "initial string" if li_std_string_extra.cvar.GlobalString2 != "global string 2": - raise RuntimeError, "GlobalString2 test 1" + raise RuntimeError, "GlobalString2 test 1" li_std_string_extra.cvar.GlobalString2 = s if li_std_string_extra.cvar.GlobalString2 != s: - raise RuntimeError, "GlobalString2 test 2" + raise RuntimeError, "GlobalString2 test 2" if li_std_string_extra.cvar.ConstGlobalString != "const global string": - raise RuntimeError, "ConstGlobalString test" + raise RuntimeError, "ConstGlobalString test" # Member variables myStructure = li_std_string_extra.Structure() if myStructure.MemberString2 != "member string 2": - raise RuntimeError, "MemberString2 test 1" + raise RuntimeError, "MemberString2 test 1" myStructure.MemberString2 = s if myStructure.MemberString2 != s: - raise RuntimeError, "MemberString2 test 2" + raise RuntimeError, "MemberString2 test 2" if myStructure.ConstMemberString != "const member string": - raise RuntimeError, "ConstMemberString test" + raise RuntimeError, "ConstMemberString test" if li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2": - raise RuntimeError, "StaticMemberString2 test 1" + raise RuntimeError, "StaticMemberString2 test 1" li_std_string_extra.cvar.Structure_StaticMemberString2 = s if li_std_string_extra.cvar.Structure_StaticMemberString2 != s: - raise RuntimeError, "StaticMemberString2 test 2" + raise RuntimeError, "StaticMemberString2 test 2" if li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string": - raise RuntimeError, "ConstStaticMemberString test" + raise RuntimeError, "ConstStaticMemberString test" if li_std_string_extra.test_reference_input("hello") != "hello": - raise RuntimeError + raise RuntimeError s = li_std_string_extra.test_reference_inout("hello") if s != "hellohello": - raise RuntimeError + raise RuntimeError if li_std_string_extra.stdstring_empty() != "": - raise RuntimeError - + raise RuntimeError + if li_std_string_extra.c_empty() != "": - raise RuntimeError + raise RuntimeError if li_std_string_extra.c_null() != None: - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/li_std_vector_enum_runme.py b/Examples/test-suite/python/li_std_vector_enum_runme.py index a2c8534f3..318d1bff6 100644 --- a/Examples/test-suite/python/li_std_vector_enum_runme.py +++ b/Examples/test-suite/python/li_std_vector_enum_runme.py @@ -1,8 +1,9 @@ import li_std_vector_enum + def check(a, b): - if (a != b): - raise RuntimeError("Not equal: ", a, b) + if (a != b): + raise RuntimeError("Not equal: ", a, b) ev = li_std_vector_enum.EnumVector() @@ -17,8 +18,7 @@ it.next() v = it.value() check(v, 20) -expected = 10 +expected = 10 for val in ev.nums: - check(val, expected) - expected += 10 - + check(val, expected) + expected += 10 diff --git a/Examples/test-suite/python/li_std_vector_extra_runme.py b/Examples/test-suite/python/li_std_vector_extra_runme.py index d24d36cb6..d541de6db 100644 --- a/Examples/test-suite/python/li_std_vector_extra_runme.py +++ b/Examples/test-suite/python/li_std_vector_extra_runme.py @@ -1,110 +1,108 @@ from li_std_vector_extra import * iv = IntVector(4) -for i in range(0,4): +for i in range(0, 4): iv[i] = i x = average(iv) -y = average([1,2,3,4]) +y = average([1, 2, 3, 4]) -a = half([10,10.5,11,11.5]) +a = half([10, 10.5, 11, 11.5]) dv = DoubleVector(10) -for i in range(0,10): - dv[i] = i/2.0 +for i in range(0, 10): + dv[i] = i / 2.0 halve_in_place(dv) bv = BoolVector(4) -bv[0]= bool(1) -bv[1]= bool(0) -bv[2]= bool(4) -bv[3]= bool(0) +bv[0] = bool(1) +bv[1] = bool(0) +bv[2] = bool(4) +bv[3] = bool(0) if bv[0] != bv[2]: - raise RuntimeError,"bad std::vector mapping" + raise RuntimeError, "bad std::vector mapping" b = B(5) -va = VecA([b,None,b,b]) +va = VecA([b, None, b, b]) if va[0].f(1) != 6: - raise RuntimeError,"bad std::vector mapping" + raise RuntimeError, "bad std::vector mapping" if vecAptr(va) != 6: - raise RuntimeError,"bad std::vector mapping" + raise RuntimeError, "bad std::vector mapping" b.val = 7 if va[3].f(1) != 8: - raise RuntimeError,"bad std::vector mapping" + raise RuntimeError, "bad std::vector mapping" ip = PtrInt() ap = new_ArrInt(10) -ArrInt_setitem(ip,0,123) -ArrInt_setitem(ap,2,123) +ArrInt_setitem(ip, 0, 123) +ArrInt_setitem(ap, 2, 123) -vi = IntPtrVector((ip,ap,None)) -if ArrInt_getitem(vi[0],0) != ArrInt_getitem(vi[1],2): - raise RuntimeError,"bad std::vector mapping" +vi = IntPtrVector((ip, ap, None)) +if ArrInt_getitem(vi[0], 0) != ArrInt_getitem(vi[1], 2): + raise RuntimeError, "bad std::vector mapping" -delete_ArrInt(ap) +delete_ArrInt(ap) -a = halfs([10,8,4,3]) +a = halfs([10, 8, 4, 3]) v = IntVector() -v[0:2] = [1,2] +v[0:2] = [1, 2] if v[0] != 1 or v[1] != 2: - raise RuntimeError,"bad setslice" + raise RuntimeError, "bad setslice" if v[0:-1][0] != 1: - raise RuntimeError,"bad getslice" + raise RuntimeError, "bad getslice" if v[0:-2].size() != 0: - raise RuntimeError,"bad getslice" + raise RuntimeError, "bad getslice" v[0:1] = [2] if v[0] != 2: - raise RuntimeError,"bad setslice" + raise RuntimeError, "bad setslice" v[1:] = [3] if v[1] != 3: - raise RuntimeError,"bad setslice" + raise RuntimeError, "bad setslice" v[2:] = [3] if v[2] != 3: - raise RuntimeError,"bad setslice" + raise RuntimeError, "bad setslice" if v[0:][0] != v[0]: - raise RuntimeError,"bad getslice" + raise RuntimeError, "bad getslice" del v[:] if v.size() != 0: - raise RuntimeError,"bad getslice" + raise RuntimeError, "bad getslice" del v[:] if v.size() != 0: - raise RuntimeError,"bad getslice" - + raise RuntimeError, "bad getslice" v = vecStr(["hello ", "world"]) if v[0] != 'hello world': - raise RuntimeError,"bad std::string+std::vector" - + raise RuntimeError, "bad std::string+std::vector" -pv = pyvector([1, "hello", (1,2)]) +pv = pyvector([1, "hello", (1, 2)]) if pv[1] != "hello": raise RuntimeError iv = IntVector(5) -for i in range(0,5): +for i in range(0, 5): iv[i] = i iv[1:3] = [] @@ -113,25 +111,25 @@ if iv[1] != 3: # Overloading checks if overloaded1(iv) != "vector": - raise RuntimeError + raise RuntimeError if overloaded1(dv) != "vector": - raise RuntimeError + raise RuntimeError if overloaded2(iv) != "vector": - raise RuntimeError + raise RuntimeError if overloaded2(dv) != "vector": - raise RuntimeError + raise RuntimeError if overloaded3(iv) != "vector *": - raise RuntimeError + raise RuntimeError if overloaded3(None) != "vector *": - raise RuntimeError + raise RuntimeError if overloaded3(100) != "int": - raise RuntimeError + raise RuntimeError # vector pointer checks @@ -139,38 +137,39 @@ ip = makeIntPtr(11) dp = makeDoublePtr(33.3) error = 0 try: - vi = IntPtrVector((ip, dp)) # check vector does not accept double * element - error = 1 + # check vector does not accept double * element + vi = IntPtrVector((ip, dp)) + error = 1 except: - pass + pass if error: - raise RuntimeError + raise RuntimeError vi = IntPtrVector((ip, makeIntPtr(22))) if extractInt(vi[0]) != 11: - raise RuntimeError + raise RuntimeError if extractInt(vi[1]) != 22: - raise RuntimeError + raise RuntimeError # vector const pointer checks csp = makeConstShortPtr(111) error = 0 try: - vcs = ConstShortPtrVector((csp, dp)) # check vector does not accept double * element - error = 1 + # check vector does not accept double * element + vcs = ConstShortPtrVector((csp, dp)) + error = 1 except: - pass + pass if error: - raise RuntimeError + raise RuntimeError vcs = ConstShortPtrVector((csp, makeConstShortPtr(222))) if extractConstShort(vcs[0]) != 111: - raise RuntimeError + raise RuntimeError if extractConstShort(vcs[1]) != 222: - raise RuntimeError - + raise RuntimeError diff --git a/Examples/test-suite/python/li_std_vector_ptr_runme.py b/Examples/test-suite/python/li_std_vector_ptr_runme.py index c5f72fde4..01c654109 100644 --- a/Examples/test-suite/python/li_std_vector_ptr_runme.py +++ b/Examples/test-suite/python/li_std_vector_ptr_runme.py @@ -5,4 +5,3 @@ ip2 = makeIntPtr(22) vi = IntPtrVector((ip1, ip2)) displayVector(vi) - diff --git a/Examples/test-suite/python/li_std_wstream_runme.py b/Examples/test-suite/python/li_std_wstream_runme.py index f7379bdf8..045645b61 100644 --- a/Examples/test-suite/python/li_std_wstream_runme.py +++ b/Examples/test-suite/python/li_std_wstream_runme.py @@ -1,13 +1,12 @@ from li_std_wstream import * - a = A() 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 +if o.str() != "A class 2345 1.435\0": + print "\"%s\"" % (o.str(),) + raise RuntimeError diff --git a/Examples/test-suite/python/li_std_wstring_runme.py b/Examples/test-suite/python/li_std_wstring_runme.py index a467ae8bc..e93196b80 100644 --- a/Examples/test-suite/python/li_std_wstring_runme.py +++ b/Examples/test-suite/python/li_std_wstring_runme.py @@ -1,85 +1,83 @@ import li_std_wstring -x=u"h" +x = u"h" if li_std_wstring.test_wcvalue(x) != x: - print li_std_wstring.test_wcvalue(x) - raise RuntimeError("bad string mapping") + print li_std_wstring.test_wcvalue(x) + raise RuntimeError("bad string mapping") -x=u"hello" +x = u"hello" if li_std_wstring.test_ccvalue(x) != x: - raise RuntimeError("bad string mapping") + raise RuntimeError("bad string mapping") if li_std_wstring.test_cvalue(x) != x: - raise RuntimeError("bad string mapping") + raise RuntimeError("bad string mapping") if li_std_wstring.test_wchar_overload(x) != x: - raise RuntimeError("bad string mapping") + raise RuntimeError("bad string mapping") if li_std_wstring.test_wchar_overload("not unicode") != "not unicode": - raise RuntimeError("bad string mapping") + raise RuntimeError("bad string mapping") if li_std_wstring.test_value(x) != x: - print x, li_std_wstring.test_value(x) - raise RuntimeError("bad string mapping") + print x, li_std_wstring.test_value(x) + raise RuntimeError("bad string mapping") if li_std_wstring.test_const_reference(x) != x: - raise RuntimeError("bad string mapping") + raise RuntimeError("bad string mapping") s = li_std_wstring.wstring(u"he") s = s + u"llo" if s != x: - print s, x - raise RuntimeError("bad string mapping") + print s, x + raise RuntimeError("bad string mapping") if s[1:4] != x[1:4]: - raise RuntimeError("bad string mapping") + raise RuntimeError("bad string mapping") if li_std_wstring.test_value(s) != x: - raise RuntimeError("bad string mapping") + raise RuntimeError("bad string mapping") if li_std_wstring.test_const_reference(s) != x: - raise RuntimeError("bad string mapping") + raise RuntimeError("bad string mapping") a = li_std_wstring.A(s) if li_std_wstring.test_value(a) != x: - raise RuntimeError("bad string mapping") + raise RuntimeError("bad string mapping") if li_std_wstring.test_const_reference(a) != x: - raise RuntimeError("bad string mapping") + raise RuntimeError("bad string mapping") b = li_std_wstring.wstring(" world") if a + b != "hello world": - raise RuntimeError("bad string mapping") - + raise RuntimeError("bad string mapping") + if a + " world" != "hello world": - raise RuntimeError("bad string mapping") + raise RuntimeError("bad string mapping") # This is expected to fail if -builtin is used # 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") + 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") - c = "hello" + b - if c.find_last_of("l") != 9: - raise RuntimeError("bad string mapping") - s = "hello world" b = li_std_wstring.B("hi") b.name = li_std_wstring.wstring(u"hello") if b.name != "hello": - raise RuntimeError("bad string mapping") + raise RuntimeError("bad string mapping") b.a = li_std_wstring.A("hello") if b.a != u"hello": - raise RuntimeError("bad string mapping") - - + raise RuntimeError("bad string mapping") diff --git a/Examples/test-suite/python/member_pointer_runme.py b/Examples/test-suite/python/member_pointer_runme.py index 3d68e916d..5ae7ab9a4 100644 --- a/Examples/test-suite/python/member_pointer_runme.py +++ b/Examples/test-suite/python/member_pointer_runme.py @@ -2,9 +2,11 @@ from member_pointer import * + def check(what, expected, actual): - if expected != actual: - raise RuntimeError ("Failed: " , what , " Expected: " , expected , " Actual: " , actual) + if expected != actual: + raise RuntimeError( + "Failed: ", what, " Expected: ", expected, " Actual: ", actual) # Get the pointers @@ -17,20 +19,20 @@ s = Square(10) # Do some calculations -check ("Square area ", 100.0, do_op(s,area_pt)) -check ("Square perim", 40.0, do_op(s,perim_pt)) +check("Square area ", 100.0, do_op(s, area_pt)) +check("Square perim", 40.0, do_op(s, perim_pt)) memberPtr = cvar.areavar memberPtr = cvar.perimetervar # Try the variables -check ("Square area ", 100.0, do_op(s,cvar.areavar)) -check ("Square perim", 40.0, do_op(s,cvar.perimetervar)) +check("Square area ", 100.0, do_op(s, cvar.areavar)) +check("Square perim", 40.0, do_op(s, cvar.perimetervar)) # Modify one of the variables cvar.areavar = perim_pt -check ("Square perimeter", 40.0, do_op(s,cvar.areavar)) +check("Square perimeter", 40.0, do_op(s, cvar.areavar)) # Try the constants @@ -38,9 +40,9 @@ memberPtr = AREAPT memberPtr = PERIMPT memberPtr = NULLPT -check ("Square area ", 100.0, do_op(s,AREAPT)) -check ("Square perim", 40.0, do_op(s,PERIMPT)) +check("Square area ", 100.0, do_op(s, AREAPT)) +check("Square perim", 40.0, do_op(s, PERIMPT)) -check ("Add by value", 3, call1(ADD_BY_VALUE, 1, 2)) -check ("Add by pointer", 7, call2(ADD_BY_POINTER, 3, 4)) -check ("Add by reference", 11, call3(ADD_BY_REFERENCE, 5, 6)) +check("Add by value", 3, call1(ADD_BY_VALUE, 1, 2)) +check("Add by pointer", 7, call2(ADD_BY_POINTER, 3, 4)) +check("Add by reference", 11, call3(ADD_BY_REFERENCE, 5, 6)) diff --git a/Examples/test-suite/python/memberin_extend_c_runme.py b/Examples/test-suite/python/memberin_extend_c_runme.py index 314761f89..da601ae2a 100644 --- a/Examples/test-suite/python/memberin_extend_c_runme.py +++ b/Examples/test-suite/python/memberin_extend_c_runme.py @@ -3,4 +3,4 @@ import memberin_extend_c t = memberin_extend_c.Person() t.name = "Fred Bloggs" if t.name != "FRED BLOGGS": - raise RuntimeError("name wrong") + raise RuntimeError("name wrong") diff --git a/Examples/test-suite/python/minherit_runme.py b/Examples/test-suite/python/minherit_runme.py index d7ad0b36b..b7e7d019c 100644 --- a/Examples/test-suite/python/minherit_runme.py +++ b/Examples/test-suite/python/minherit_runme.py @@ -10,26 +10,28 @@ if a.xget() != 1: raise RuntimeError, "Bad attribute value" if b.yget() != 2: - raise RuntimeError, "Bad attribute value" + raise RuntimeError, "Bad attribute value" if c.xget() != 1 or c.yget() != 2 or c.zget() != 3: - raise RuntimeError, "Bad attribute value" + raise RuntimeError, "Bad attribute value" if d.xget() != 1 or d.yget() != 2 or d.zget() != 3 or d.wget() != 4: - raise RuntimeError, "Bad attribute value" + raise RuntimeError, "Bad attribute value" if minherit.xget(a) != 1: - raise RuntimeError, "Bad attribute value %d" % (minherit.xget(a)) + raise RuntimeError, "Bad attribute value %d" % (minherit.xget(a)) if minherit.yget(b) != 2: - raise RuntimeError, "Bad attribute value %d" % (minherit.yget(b)) + raise RuntimeError, "Bad attribute value %d" % (minherit.yget(b)) if minherit.xget(c) != 1 or minherit.yget(c) != 2 or minherit.zget(c) != 3: - raise RuntimeError, "Bad attribute value %d %d %d" % (minherit.xget(c), minherit.yget(c), minherit.zget(c)) + raise RuntimeError, "Bad attribute value %d %d %d" % ( + minherit.xget(c), minherit.yget(c), minherit.zget(c)) if minherit.xget(d) != 1 or minherit.yget(d) != 2 or minherit.zget(d) != 3 or minherit.wget(d) != 4: - raise RuntimeError, "Bad attribute value %d %d %d %d" % (minherit.xget(d), minherit.yget(d), minherit.zget(d), minherit.wget(d)) + raise RuntimeError, "Bad attribute value %d %d %d %d" % ( + minherit.xget(d), minherit.yget(d), minherit.zget(d), minherit.wget(d)) # Cleanse all of the pointers and see what happens @@ -42,30 +44,24 @@ if aa.xget() != 1: raise RuntimeError, "Bad attribute value" if bb.yget() != 2: - raise RuntimeError, "Bad attribute value" + raise RuntimeError, "Bad attribute value" if cc.xget() != 1 or cc.yget() != 2 or cc.zget() != 3: - raise RuntimeError, "Bad attribute value" + raise RuntimeError, "Bad attribute value" if dd.xget() != 1 or dd.yget() != 2 or dd.zget() != 3 or dd.wget() != 4: - raise RuntimeError, "Bad attribute value" + raise RuntimeError, "Bad attribute value" if minherit.xget(aa) != 1: - raise RuntimeError, "Bad attribute value %d" % (minherit.xget(aa)) + raise RuntimeError, "Bad attribute value %d" % (minherit.xget(aa)) if minherit.yget(bb) != 2: - raise RuntimeError, "Bad attribute value %d" % (minherit.yget(bb)) + raise RuntimeError, "Bad attribute value %d" % (minherit.yget(bb)) if minherit.xget(cc) != 1 or minherit.yget(cc) != 2 or minherit.zget(cc) != 3: - raise RuntimeError, "Bad attribute value %d %d %d" % (minherit.xget(cc), minherit.yget(cc), minherit.zget(cc)) + raise RuntimeError, "Bad attribute value %d %d %d" % ( + minherit.xget(cc), minherit.yget(cc), minherit.zget(cc)) if minherit.xget(dd) != 1 or minherit.yget(dd) != 2 or minherit.zget(dd) != 3 or minherit.wget(dd) != 4: - raise RuntimeError, "Bad attribute value %d %d %d %d" % (minherit.xget(dd), minherit.yget(dd), minherit.zget(dd), minherit.wget(dd)) - - - - - - - - + raise RuntimeError, "Bad attribute value %d %d %d %d" % ( + minherit.xget(dd), minherit.yget(dd), minherit.zget(dd), minherit.wget(dd)) diff --git a/Examples/test-suite/python/multi_import_runme.py b/Examples/test-suite/python/multi_import_runme.py index f8a2f19c7..27f86a9ef 100644 --- a/Examples/test-suite/python/multi_import_runme.py +++ b/Examples/test-suite/python/multi_import_runme.py @@ -3,16 +3,16 @@ import multi_import_b x = multi_import_b.XXX() if x.testx() != 0: - raise RuntimeError + raise RuntimeError y = multi_import_b.YYY() if y.testx() != 0: - raise RuntimeError + raise RuntimeError if y.testy() != 1: - raise RuntimeError + raise RuntimeError z = multi_import_a.ZZZ() if z.testx() != 0: - raise RuntimeError + raise RuntimeError if z.testz() != 2: - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/namespace_class_runme.py b/Examples/test-suite/python/namespace_class_runme.py index e009f9515..e0bd3ca09 100644 --- a/Examples/test-suite/python/namespace_class_runme.py +++ b/Examples/test-suite/python/namespace_class_runme.py @@ -1,30 +1,31 @@ from namespace_class import * + def is_new_style_class(cls): - return hasattr(cls, "__class__") + return hasattr(cls, "__class__") try: - p = Private1() - error = 1 + p = Private1() + error = 1 except: - error = 0 + error = 0 if (error): - raise RuntimeError, "Private1 is private" + raise RuntimeError, "Private1 is private" try: - p = Private2() - error = 1 + p = Private2() + error = 1 except: - error = 0 + error = 0 if (error): - raise RuntimeError, "Private2 is private" + raise RuntimeError, "Private2 is private" if is_new_style_class(EulerT3D): - EulerT3D.toFrame(1,1,1) + EulerT3D.toFrame(1, 1, 1) else: - EulerT3D().toFrame(1,1,1) + EulerT3D().toFrame(1, 1, 1) b = BooT_i() b = BooT_H() @@ -40,6 +41,6 @@ f = FooT_H() f.foo(Hi) if is_new_style_class(FooT_H): - f_type = str(type(f)) - if f_type.find("'namespace_class.FooT_H'") == -1: - raise RuntimeError("Incorrect type: " + f_type) + f_type = str(type(f)) + if f_type.find("'namespace_class.FooT_H'") == -1: + raise RuntimeError("Incorrect type: " + f_type) diff --git a/Examples/test-suite/python/namespace_typemap_runme.py b/Examples/test-suite/python/namespace_typemap_runme.py index 682ad3bb1..14379496d 100644 --- a/Examples/test-suite/python/namespace_typemap_runme.py +++ b/Examples/test-suite/python/namespace_typemap_runme.py @@ -36,7 +36,7 @@ if stest11("hello") != "hello": if stest12("hello") != "hello": raise RuntimeError -c = complex(2,3) +c = complex(2, 3) r = c.real if ctest1(c) != r: diff --git a/Examples/test-suite/python/nested_template_base_runme.py b/Examples/test-suite/python/nested_template_base_runme.py index 3d54b8391..fc5844300 100644 --- a/Examples/test-suite/python/nested_template_base_runme.py +++ b/Examples/test-suite/python/nested_template_base_runme.py @@ -1,13 +1,13 @@ from nested_template_base import * -ois = InnerS(123); -oic = InnerC(); +ois = InnerS(123) +oic = InnerC() # Check base method is available if (oic.outer(ois).val != 123): - raise RuntimeError("Wrong value calling outer"); + 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"); + raise RuntimeError("Wrong value calling innerc") diff --git a/Examples/test-suite/python/nested_workaround_runme.py b/Examples/test-suite/python/nested_workaround_runme.py index a8a75d370..c11299ed4 100644 --- a/Examples/test-suite/python/nested_workaround_runme.py +++ b/Examples/test-suite/python/nested_workaround_runme.py @@ -4,10 +4,10 @@ inner = Inner(5) outer = Outer() newInner = outer.doubleInnerValue(inner) if newInner.getValue() != 10: - raise RuntimeError + raise RuntimeError outer = Outer() inner = outer.createInner(3) newInner = outer.doubleInnerValue(inner) if outer.getInnerValue(newInner) != 6: - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/operbool_runme.py b/Examples/test-suite/python/operbool_runme.py index 4218b5dd4..708dea786 100644 --- a/Examples/test-suite/python/operbool_runme.py +++ b/Examples/test-suite/python/operbool_runme.py @@ -1,4 +1,3 @@ #!/usr/bin/env python import operbool assert not operbool.Test() - diff --git a/Examples/test-suite/python/overload_bool_runme.py b/Examples/test-suite/python/overload_bool_runme.py index ed7d1b5a1..8192b37ce 100644 --- a/Examples/test-suite/python/overload_bool_runme.py +++ b/Examples/test-suite/python/overload_bool_runme.py @@ -2,25 +2,25 @@ import overload_bool # Overloading bool, int, string if overload_bool.overloaded(True) != "bool": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") if overload_bool.overloaded(False) != "bool": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") if overload_bool.overloaded(0) != "int": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") if overload_bool.overloaded(1) != "int": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") if overload_bool.overloaded(2) != "int": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") if overload_bool.overloaded("1234") != "string": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") # Test bool masquerading as int if overload_bool.intfunction(True) != "int": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") if overload_bool.intfunction(False) != "int": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") # Test int masquerading as bool # Not possible @@ -30,26 +30,25 @@ if overload_bool.intfunction(False) != "int": # Overloading bool, int, string if overload_bool.overloaded_ref(True) != "bool": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") if overload_bool.overloaded_ref(False) != "bool": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") if overload_bool.overloaded_ref(0) != "int": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") if overload_bool.overloaded_ref(1) != "int": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") if overload_bool.overloaded_ref(2) != "int": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") if overload_bool.overloaded_ref("1234") != "string": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") # Test bool masquerading as int if overload_bool.intfunction_ref(True) != "int": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") if overload_bool.intfunction_ref(False) != "int": - raise RuntimeError("wrong!") + raise RuntimeError("wrong!") # Test int masquerading as bool # Not possible - diff --git a/Examples/test-suite/python/overload_complicated_runme.py b/Examples/test-suite/python/overload_complicated_runme.py index 2b7467d4d..9c039a0a5 100644 --- a/Examples/test-suite/python/overload_complicated_runme.py +++ b/Examples/test-suite/python/overload_complicated_runme.py @@ -7,41 +7,41 @@ p = Pop(pInt) p = Pop(pInt, 0) -# Check overloaded in const only and pointers/references which target languages cannot disambiguate +# Check overloaded in const only and pointers/references which target +# languages cannot disambiguate if p.hip(0) != 701: - raise RuntimeError,"Test 1 failed" + raise RuntimeError, "Test 1 failed" if p.hip(pInt) != 702: - raise RuntimeError,"Test 2 failed" + raise RuntimeError, "Test 2 failed" # Reverse the order for the above if p.hop(pInt) != 805: - raise RuntimeError,"Test 3 failed" + raise RuntimeError, "Test 3 failed" if p.hop(0) != 801: - raise RuntimeError,"Test 4 failed" + raise RuntimeError, "Test 4 failed" # Few more variations and order shuffled if p.pop(0) != 901: - raise RuntimeError,"Test 5 failed" + raise RuntimeError, "Test 5 failed" if p.pop(pInt) != 902: - raise RuntimeError,"Test 6 failed" + raise RuntimeError, "Test 6 failed" if p.pop() != 905: - raise RuntimeError,"Test 7 failed" + raise RuntimeError, "Test 7 failed" # Overload on const only if p.bop(pInt) != 1001: - raise RuntimeError,"Test 8 failed" + raise RuntimeError, "Test 8 failed" if p.bip(pInt) != 2001: - raise RuntimeError,"Test 9 failed" + raise RuntimeError, "Test 9 failed" # Globals if muzak(0) != 3001: - raise RuntimeError,"Test 10 failed" + raise RuntimeError, "Test 10 failed" if muzak(pInt) != 3002: - raise RuntimeError,"Test 11 failed" - + raise RuntimeError, "Test 11 failed" diff --git a/Examples/test-suite/python/overload_extend_runme.py b/Examples/test-suite/python/overload_extend_runme.py index 7d08d482b..4a8a0165e 100644 --- a/Examples/test-suite/python/overload_extend_runme.py +++ b/Examples/test-suite/python/overload_extend_runme.py @@ -7,8 +7,7 @@ if f.test(3) != 1: raise RuntimeError if f.test("hello") != 2: raise RuntimeError -if f.test(3,2) != 5: +if f.test(3, 2) != 5: raise RuntimeError if f.test(3.0) != 1003: raise RuntimeError - diff --git a/Examples/test-suite/python/overload_extendc_runme.py b/Examples/test-suite/python/overload_extendc_runme.py index cea3ea618..ffd074a9d 100644 --- a/Examples/test-suite/python/overload_extendc_runme.py +++ b/Examples/test-suite/python/overload_extendc_runme.py @@ -5,18 +5,17 @@ if f.test(3) != 1: raise RuntimeError if f.test("hello") != 2: raise RuntimeError -if f.test(3.5,2.5) != 3: +if f.test(3.5, 2.5) != 3: raise RuntimeError -if f.test("hello",20) != 1020: +if f.test("hello", 20) != 1020: raise RuntimeError -if f.test("hello",20,100) != 120: +if f.test("hello", 20, 100) != 120: raise RuntimeError # C default args if f.test(f) != 30: raise RuntimeError -if f.test(f,100) != 120: +if f.test(f, 100) != 120: raise RuntimeError -if f.test(f,100,200) != 300: +if f.test(f, 100, 200) != 300: raise RuntimeError - diff --git a/Examples/test-suite/python/overload_numeric_runme.py b/Examples/test-suite/python/overload_numeric_runme.py index 639fb5e5d..9f3382d86 100644 --- a/Examples/test-suite/python/overload_numeric_runme.py +++ b/Examples/test-suite/python/overload_numeric_runme.py @@ -5,9 +5,10 @@ import math nums = Nums() limits = Limits() + def check(got, expected): - if got != expected: - raise RuntimeError("got: " + got + " expected: " + expected) + if got != expected: + raise RuntimeError("got: " + got + " expected: " + expected) check(nums.over(0), "signed char") check(nums.over(0.0), "float") @@ -15,21 +16,21 @@ check(nums.over(0.0), "float") check(nums.over(limits.schar_min()), "signed char") check(nums.over(limits.schar_max()), "signed char") -check(nums.over(limits.schar_min()-1), "short") -check(nums.over(limits.schar_max()+1), "short") +check(nums.over(limits.schar_min() - 1), "short") +check(nums.over(limits.schar_max() + 1), "short") check(nums.over(limits.shrt_min()), "short") check(nums.over(limits.shrt_max()), "short") -check(nums.over(limits.shrt_min()-1), "int") -check(nums.over(limits.shrt_max()+1), "int") +check(nums.over(limits.shrt_min() - 1), "int") +check(nums.over(limits.shrt_max() + 1), "int") check(nums.over(limits.int_min()), "int") check(nums.over(limits.int_max()), "int") check(nums.over(limits.flt_min()), "float") check(nums.over(limits.flt_max()), "float") -check(nums.over(limits.flt_max()*10), "double") -check(nums.over(-limits.flt_max()*10), "double") +check(nums.over(limits.flt_max() * 10), "double") +check(nums.over(-limits.flt_max() * 10), "double") check(nums.over(limits.dbl_max()), "double") check(nums.over(-limits.dbl_max()), "double") diff --git a/Examples/test-suite/python/overload_rename_runme.py b/Examples/test-suite/python/overload_rename_runme.py index b192f7d5d..dcad1b95a 100644 --- a/Examples/test-suite/python/overload_rename_runme.py +++ b/Examples/test-suite/python/overload_rename_runme.py @@ -2,7 +2,6 @@ import overload_rename f = overload_rename.Foo(1) -f = overload_rename.Foo(1,1) -f = overload_rename.Foo_int(1,1) -f = overload_rename.Foo_int(1,1,1) - +f = overload_rename.Foo(1, 1) +f = overload_rename.Foo_int(1, 1) +f = overload_rename.Foo_int(1, 1, 1) diff --git a/Examples/test-suite/python/overload_simple_runme.py b/Examples/test-suite/python/overload_simple_runme.py index a78f3720a..6d72ec081 100644 --- a/Examples/test-suite/python/overload_simple_runme.py +++ b/Examples/test-suite/python/overload_simple_runme.py @@ -70,7 +70,7 @@ if s.type != "none": s = Spam(3) if s.type != "int": raise RuntimeError, "Spam(int)" - + s = Spam(3.4) if s.type != "double": raise RuntimeError, "Spam(double)" @@ -92,9 +92,6 @@ if s.type != "void *": raise RuntimeError, "Spam(void *)" - - - free_void(v) diff --git a/Examples/test-suite/python/overload_subtype_runme.py b/Examples/test-suite/python/overload_subtype_runme.py index 6bf77dc59..3f32a5583 100644 --- a/Examples/test-suite/python/overload_subtype_runme.py +++ b/Examples/test-suite/python/overload_subtype_runme.py @@ -8,4 +8,3 @@ if spam(f) != 1: if spam(b) != 2: raise RuntimeError, "bar" - diff --git a/Examples/test-suite/python/overload_template_fast_runme.py b/Examples/test-suite/python/overload_template_fast_runme.py index 299b91db8..95349a9b1 100644 --- a/Examples/test-suite/python/overload_template_fast_runme.py +++ b/Examples/test-suite/python/overload_template_fast_runme.py @@ -1,83 +1,84 @@ from overload_template_fast import * + def is_new_style_class(cls): - return hasattr(cls, "__class__") + return hasattr(cls, "__class__") f = foo() -a = maximum(3,4) -b = maximum(3.4,5.2) +a = maximum(3, 4) +b = maximum(3.4, 5.2) # mix 1 if (mix1("hi") != 101): - raise RuntimeError, ("mix1(const char*)") + raise RuntimeError, ("mix1(const char*)") if (mix1(1.0, 1.0) != 102): - raise RuntimeError, ("mix1(double, const double &)") + raise RuntimeError, ("mix1(double, const double &)") if (mix1(1.0) != 103): - raise RuntimeError, ("mix1(double)") + raise RuntimeError, ("mix1(double)") # mix 2 if (mix2("hi") != 101): - raise RuntimeError, ("mix2(const char*)") + raise RuntimeError, ("mix2(const char*)") if (mix2(1.0, 1.0) != 102): - raise RuntimeError, ("mix2(double, const double &)") + raise RuntimeError, ("mix2(double, const double &)") if (mix2(1.0) != 103): - raise RuntimeError, ("mix2(double)") + raise RuntimeError, ("mix2(double)") # mix 3 if (mix3("hi") != 101): - raise RuntimeError, ("mix3(const char*)") + raise RuntimeError, ("mix3(const char*)") if (mix3(1.0, 1.0) != 102): - raise RuntimeError, ("mix3(double, const double &)") + raise RuntimeError, ("mix3(double, const double &)") if (mix3(1.0) != 103): - raise RuntimeError, ("mix3(double)") + raise RuntimeError, ("mix3(double)") # Combination 1 if (overtparams1(100) != 10): - raise RuntimeError, ("overtparams1(int)") + raise RuntimeError, ("overtparams1(int)") if (overtparams1(100.0, 100) != 20): - raise RuntimeError, ("overtparams1(double, int)") + raise RuntimeError, ("overtparams1(double, int)") # Combination 2 if (overtparams2(100.0, 100) != 40): - raise RuntimeError, ("overtparams2(double, int)") + raise RuntimeError, ("overtparams2(double, int)") # Combination 3 if (overloaded() != 60): - raise RuntimeError, ("overloaded()") + raise RuntimeError, ("overloaded()") if (overloaded(100.0, 100) != 70): - raise RuntimeError, ("overloaded(double, int)") + raise RuntimeError, ("overloaded(double, int)") # Combination 4 if (overloadedagain("hello") != 80): - raise RuntimeError, ("overloadedagain(const char *)") + raise RuntimeError, ("overloadedagain(const char *)") if (overloadedagain() != 90): - raise RuntimeError, ("overloadedagain(double)") + raise RuntimeError, ("overloadedagain(double)") # specializations if (specialization(10) != 202): - raise RuntimeError, ("specialization(int)") + raise RuntimeError, ("specialization(int)") if (specialization(10.0) != 203): - raise RuntimeError, ("specialization(double)") + raise RuntimeError, ("specialization(double)") if (specialization(10, 10) != 204): - raise RuntimeError, ("specialization(int, int)") + raise RuntimeError, ("specialization(int, int)") if (specialization(10.0, 10.0) != 205): - raise RuntimeError, ("specialization(double, double)") + raise RuntimeError, ("specialization(double, double)") if (specialization("hi", "hi") != 201): - raise RuntimeError, ("specialization(const char *, const char *)") + raise RuntimeError, ("specialization(const char *, const char *)") # simple specialization @@ -87,66 +88,66 @@ xyz_double() # a bit of everything if (overload("hi") != 0): - raise RuntimeError, ("overload()") + raise RuntimeError, ("overload()") if (overload(1) != 10): - raise RuntimeError, ("overload(int t)") + raise RuntimeError, ("overload(int t)") if (overload(1, 1) != 20): - raise RuntimeError, ("overload(int t, const int &)") + raise RuntimeError, ("overload(int t, const int &)") if (overload(1, "hello") != 30): - raise RuntimeError, ("overload(int t, const char *)") + raise RuntimeError, ("overload(int t, const char *)") k = Klass() if (overload(k) != 10): - raise RuntimeError, ("overload(Klass t)") + raise RuntimeError, ("overload(Klass t)") if (overload(k, k) != 20): - raise RuntimeError, ("overload(Klass t, const Klass &)") + raise RuntimeError, ("overload(Klass t, const Klass &)") if (overload(k, "hello") != 30): - raise RuntimeError, ("overload(Klass t, const char *)") + raise RuntimeError, ("overload(Klass t, const char *)") if (overload(10.0, "hi") != 40): - raise RuntimeError, ("overload(double t, const char *)") + raise RuntimeError, ("overload(double t, const char *)") if (overload() != 50): - raise RuntimeError, ("overload(const char *)") + raise RuntimeError, ("overload(const char *)") # everything put in a namespace if (nsoverload("hi") != 1000): - raise RuntimeError, ("nsoverload()") + raise RuntimeError, ("nsoverload()") if (nsoverload(1) != 1010): - raise RuntimeError, ("nsoverload(int t)") + raise RuntimeError, ("nsoverload(int t)") if (nsoverload(1, 1) != 1020): - raise RuntimeError, ("nsoverload(int t, const int &)") + raise RuntimeError, ("nsoverload(int t, const int &)") if (nsoverload(1, "hello") != 1030): - raise RuntimeError, ("nsoverload(int t, const char *)") + raise RuntimeError, ("nsoverload(int t, const char *)") if (nsoverload(k) != 1010): - raise RuntimeError, ("nsoverload(Klass t)") + raise RuntimeError, ("nsoverload(Klass t)") if (nsoverload(k, k) != 1020): - raise RuntimeError, ("nsoverload(Klass t, const Klass &)") + raise RuntimeError, ("nsoverload(Klass t, const Klass &)") if (nsoverload(k, "hello") != 1030): - raise RuntimeError, ("nsoverload(Klass t, const char *)") + raise RuntimeError, ("nsoverload(Klass t, const char *)") if (nsoverload(10.0, "hi") != 1040): - raise RuntimeError, ("nsoverload(double t, const char *)") + raise RuntimeError, ("nsoverload(double t, const char *)") if (nsoverload() != 1050): - raise RuntimeError, ("nsoverload(const char *)") + raise RuntimeError, ("nsoverload(const char *)") if is_new_style_class(A): - A.foo(1) + A.foo(1) else: - A_foo(1) + A_foo(1) b = B() b.foo(1) diff --git a/Examples/test-suite/python/overload_template_runme.py b/Examples/test-suite/python/overload_template_runme.py index c1337ba6a..014ec71cb 100644 --- a/Examples/test-suite/python/overload_template_runme.py +++ b/Examples/test-suite/python/overload_template_runme.py @@ -1,79 +1,79 @@ from overload_template import * f = foo() -a = maximum(3,4) -b = maximum(3.4,5.2) +a = maximum(3, 4) +b = maximum(3.4, 5.2) # mix 1 if (mix1("hi") != 101): - raise RuntimeError, ("mix1(const char*)") + raise RuntimeError, ("mix1(const char*)") if (mix1(1.0, 1.0) != 102): - raise RuntimeError, ("mix1(double, const double &)") + raise RuntimeError, ("mix1(double, const double &)") if (mix1(1.0) != 103): - raise RuntimeError, ("mix1(double)") + raise RuntimeError, ("mix1(double)") # mix 2 if (mix2("hi") != 101): - raise RuntimeError, ("mix2(const char*)") + raise RuntimeError, ("mix2(const char*)") if (mix2(1.0, 1.0) != 102): - raise RuntimeError, ("mix2(double, const double &)") + raise RuntimeError, ("mix2(double, const double &)") if (mix2(1.0) != 103): - raise RuntimeError, ("mix2(double)") + raise RuntimeError, ("mix2(double)") # mix 3 if (mix3("hi") != 101): - raise RuntimeError, ("mix3(const char*)") + raise RuntimeError, ("mix3(const char*)") if (mix3(1.0, 1.0) != 102): - raise RuntimeError, ("mix3(double, const double &)") + raise RuntimeError, ("mix3(double, const double &)") if (mix3(1.0) != 103): - raise RuntimeError, ("mix3(double)") + raise RuntimeError, ("mix3(double)") # Combination 1 if (overtparams1(100) != 10): - raise RuntimeError, ("overtparams1(int)") + raise RuntimeError, ("overtparams1(int)") if (overtparams1(100.0, 100) != 20): - raise RuntimeError, ("overtparams1(double, int)") + raise RuntimeError, ("overtparams1(double, int)") # Combination 2 if (overtparams2(100.0, 100) != 40): - raise RuntimeError, ("overtparams2(double, int)") + raise RuntimeError, ("overtparams2(double, int)") # Combination 3 if (overloaded() != 60): - raise RuntimeError, ("overloaded()") + raise RuntimeError, ("overloaded()") if (overloaded(100.0, 100) != 70): - raise RuntimeError, ("overloaded(double, int)") + raise RuntimeError, ("overloaded(double, int)") # Combination 4 if (overloadedagain("hello") != 80): - raise RuntimeError, ("overloadedagain(const char *)") + raise RuntimeError, ("overloadedagain(const char *)") if (overloadedagain() != 90): - raise RuntimeError, ("overloadedagain(double)") + raise RuntimeError, ("overloadedagain(double)") # specializations if (specialization(10) != 202): - raise RuntimeError, ("specialization(int)") + raise RuntimeError, ("specialization(int)") if (specialization(10.0) != 203): - raise RuntimeError, ("specialization(double)") + raise RuntimeError, ("specialization(double)") if (specialization(10, 10) != 204): - raise RuntimeError, ("specialization(int, int)") + raise RuntimeError, ("specialization(int, int)") if (specialization(10.0, 10.0) != 205): - raise RuntimeError, ("specialization(double, double)") + raise RuntimeError, ("specialization(double, double)") if (specialization("hi", "hi") != 201): - raise RuntimeError, ("specialization(const char *, const char *)") + raise RuntimeError, ("specialization(const char *, const char *)") # simple specialization @@ -83,61 +83,61 @@ xyz_double() # a bit of everything if (overload("hi") != 0): - raise RuntimeError, ("overload()") + raise RuntimeError, ("overload()") if (overload(1) != 10): - raise RuntimeError, ("overload(int t)") + raise RuntimeError, ("overload(int t)") if (overload(1, 1) != 20): - raise RuntimeError, ("overload(int t, const int &)") + raise RuntimeError, ("overload(int t, const int &)") if (overload(1, "hello") != 30): - raise RuntimeError, ("overload(int t, const char *)") + raise RuntimeError, ("overload(int t, const char *)") k = Klass() if (overload(k) != 10): - raise RuntimeError, ("overload(Klass t)") + raise RuntimeError, ("overload(Klass t)") if (overload(k, k) != 20): - raise RuntimeError, ("overload(Klass t, const Klass &)") + raise RuntimeError, ("overload(Klass t, const Klass &)") if (overload(k, "hello") != 30): - raise RuntimeError, ("overload(Klass t, const char *)") + raise RuntimeError, ("overload(Klass t, const char *)") if (overload(10.0, "hi") != 40): - raise RuntimeError, ("overload(double t, const char *)") + raise RuntimeError, ("overload(double t, const char *)") if (overload() != 50): - raise RuntimeError, ("overload(const char *)") + raise RuntimeError, ("overload(const char *)") # everything put in a namespace if (nsoverload("hi") != 1000): - raise RuntimeError, ("nsoverload()") + raise RuntimeError, ("nsoverload()") if (nsoverload(1) != 1010): - raise RuntimeError, ("nsoverload(int t)") + raise RuntimeError, ("nsoverload(int t)") if (nsoverload(1, 1) != 1020): - raise RuntimeError, ("nsoverload(int t, const int &)") + raise RuntimeError, ("nsoverload(int t, const int &)") if (nsoverload(1, "hello") != 1030): - raise RuntimeError, ("nsoverload(int t, const char *)") + raise RuntimeError, ("nsoverload(int t, const char *)") if (nsoverload(k) != 1010): - raise RuntimeError, ("nsoverload(Klass t)") + raise RuntimeError, ("nsoverload(Klass t)") if (nsoverload(k, k) != 1020): - raise RuntimeError, ("nsoverload(Klass t, const Klass &)") + raise RuntimeError, ("nsoverload(Klass t, const Klass &)") if (nsoverload(k, "hello") != 1030): - raise RuntimeError, ("nsoverload(Klass t, const char *)") + raise RuntimeError, ("nsoverload(Klass t, const char *)") if (nsoverload(10.0, "hi") != 1040): - raise RuntimeError, ("nsoverload(double t, const char *)") + raise RuntimeError, ("nsoverload(double t, const char *)") if (nsoverload() != 1050): - raise RuntimeError, ("nsoverload(const char *)") + raise RuntimeError, ("nsoverload(const char *)") A_foo(1) diff --git a/Examples/test-suite/python/pointer_reference_runme.py b/Examples/test-suite/python/pointer_reference_runme.py index e1a1a1f4b..b9b47881d 100644 --- a/Examples/test-suite/python/pointer_reference_runme.py +++ b/Examples/test-suite/python/pointer_reference_runme.py @@ -2,15 +2,15 @@ import pointer_reference s = pointer_reference.get() if s.value != 10: - raise RuntimeError, "get test failed" + raise RuntimeError, "get test failed" ss = pointer_reference.Struct(20) pointer_reference.set(ss) if pointer_reference.cvar.Struct_instance.value != 20: - raise RuntimeError, "set test failed" + raise RuntimeError, "set test failed" if pointer_reference.overloading(1) != 111: - raise RuntimeError, "overload test 1 failed" + raise RuntimeError, "overload test 1 failed" if pointer_reference.overloading(ss) != 222: - raise RuntimeError, "overload test 2 failed" + raise RuntimeError, "overload test 2 failed" diff --git a/Examples/test-suite/python/preproc_defined_runme.py b/Examples/test-suite/python/preproc_defined_runme.py index 9a295533a..af46816be 100644 --- a/Examples/test-suite/python/preproc_defined_runme.py +++ b/Examples/test-suite/python/preproc_defined_runme.py @@ -1,7 +1,7 @@ import preproc_defined if preproc_defined.call_checking() != 1: - raise RuntimeError + raise RuntimeError d = preproc_defined.Defined() d.defined = 10 diff --git a/Examples/test-suite/python/preproc_include_runme.py b/Examples/test-suite/python/preproc_include_runme.py index 778de3c87..7c3a360ce 100644 --- a/Examples/test-suite/python/preproc_include_runme.py +++ b/Examples/test-suite/python/preproc_include_runme.py @@ -1,23 +1,22 @@ import preproc_include if preproc_include.multiply10(10) != 100: - raise RuntimeError + raise RuntimeError if preproc_include.multiply20(10) != 200: - raise RuntimeError + raise RuntimeError if preproc_include.multiply30(10) != 300: - raise RuntimeError + raise RuntimeError if preproc_include.multiply40(10) != 400: - raise RuntimeError + raise RuntimeError if preproc_include.multiply50(10) != 500: - raise RuntimeError + raise RuntimeError if preproc_include.multiply60(10) != 600: - raise RuntimeError + raise RuntimeError if preproc_include.multiply70(10) != 700: - raise RuntimeError - + raise RuntimeError diff --git a/Examples/test-suite/python/preproc_runme.py b/Examples/test-suite/python/preproc_runme.py index 3049f00ab..99a6d0307 100644 --- a/Examples/test-suite/python/preproc_runme.py +++ b/Examples/test-suite/python/preproc_runme.py @@ -1,16 +1,16 @@ import preproc if preproc.endif != 1: - raise RuntimeError + raise RuntimeError if preproc.define != 1: - raise RuntimeError + raise RuntimeError if preproc.defined != 1: - raise RuntimeError + raise RuntimeError -if 2*preproc.one != preproc.two: - raise RuntimeError +if 2 * preproc.one != preproc.two: + raise RuntimeError if preproc.methodX(99) != 199: - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py index d4173b7d3..2e7ed7db7 100644 --- a/Examples/test-suite/python/primitive_types_runme.py +++ b/Examples/test-suite/python/primitive_types_runme.py @@ -28,81 +28,142 @@ cvar.var_paramc = sct_paramc v_check() -def pyerror(name, val, cte): - print "bad val/cte", name, val, cte - raise RuntimeError - pass -if cvar.var_bool != cct_bool: pyerror("bool", cvar.var_bool, cct_bool) -if cvar.var_schar != cct_schar: pyerror("schar", cvar.var_schar, cct_schar) -if cvar.var_uchar != cct_uchar: pyerror("uchar", cvar.var_uchar, cct_uchar) -if cvar.var_int != cct_int: pyerror("int", cvar.var_int, cct_int) -if cvar.var_uint != cct_uint: pyerror("uint", cvar.var_uint, cct_uint) -if cvar.var_short != cct_short: pyerror("short", cvar.var_short, cct_short) -if cvar.var_ushort != cct_ushort: pyerror("ushort", cvar.var_ushort, cct_ushort) -if cvar.var_long != cct_long: pyerror("long", cvar.var_long, cct_long) -if cvar.var_ulong != cct_ulong: pyerror("ulong", cvar.var_ulong, cct_ulong) -if cvar.var_llong != cct_llong: pyerror("llong", cvar.var_llong, cct_llong) -if cvar.var_ullong != cct_ullong: pyerror("ullong", cvar.var_ullong, cct_ullong) -if cvar.var_char != cct_char: pyerror("char", cvar.var_char, cct_char) -if cvar.var_pchar != cct_pchar: pyerror("pchar", cvar.var_pchar, cct_pchar) -if cvar.var_pcharc != cct_pcharc: pyerror("pchar", cvar.var_pcharc, cct_pcharc) -if cvar.var_pint != cct_pint: pyerror("pint", cvar.var_pint, cct_pint) -if cvar.var_sizet != cct_sizet: pyerror("sizet", cvar.var_sizet, cct_sizet) -if cvar.var_hello != cct_hello: pyerror("hello", cvar.var_hello, cct_hello) -if cvar.var_myint != cct_myint: pyerror("myint", cvar.var_myint, cct_myint) -if cvar.var_namet != def_namet: pyerror("name", cvar.var_namet, def_namet) +def pyerror(name, val, cte): + print "bad val/cte", name, val, cte + raise RuntimeError + pass + +if cvar.var_bool != cct_bool: + pyerror("bool", cvar.var_bool, cct_bool) +if cvar.var_schar != cct_schar: + pyerror("schar", cvar.var_schar, cct_schar) +if cvar.var_uchar != cct_uchar: + pyerror("uchar", cvar.var_uchar, cct_uchar) +if cvar.var_int != cct_int: + pyerror("int", cvar.var_int, cct_int) +if cvar.var_uint != cct_uint: + pyerror("uint", cvar.var_uint, cct_uint) +if cvar.var_short != cct_short: + pyerror("short", cvar.var_short, cct_short) +if cvar.var_ushort != cct_ushort: + pyerror("ushort", cvar.var_ushort, cct_ushort) +if cvar.var_long != cct_long: + pyerror("long", cvar.var_long, cct_long) +if cvar.var_ulong != cct_ulong: + pyerror("ulong", cvar.var_ulong, cct_ulong) +if cvar.var_llong != cct_llong: + pyerror("llong", cvar.var_llong, cct_llong) +if cvar.var_ullong != cct_ullong: + pyerror("ullong", cvar.var_ullong, cct_ullong) +if cvar.var_char != cct_char: + pyerror("char", cvar.var_char, cct_char) +if cvar.var_pchar != cct_pchar: + pyerror("pchar", cvar.var_pchar, cct_pchar) +if cvar.var_pcharc != cct_pcharc: + pyerror("pchar", cvar.var_pcharc, cct_pcharc) +if cvar.var_pint != cct_pint: + pyerror("pint", cvar.var_pint, cct_pint) +if cvar.var_sizet != cct_sizet: + pyerror("sizet", cvar.var_sizet, cct_sizet) +if cvar.var_hello != cct_hello: + pyerror("hello", cvar.var_hello, cct_hello) +if cvar.var_myint != cct_myint: + pyerror("myint", cvar.var_myint, cct_myint) +if cvar.var_namet != def_namet: + pyerror("name", cvar.var_namet, def_namet) + class PyTest (TestDirector): - def __init__(self): - TestDirector.__init__(self) + + def __init__(self): + TestDirector.__init__(self) + pass + + def ident(self, x): + return x + + def vval_bool(self, x): return self.ident(x) + + def vval_schar(self, x): return self.ident(x) + + def vval_uchar(self, x): return self.ident(x) + + def vval_int(self, x): return self.ident(x) + + def vval_uint(self, x): return self.ident(x) + + def vval_short(self, x): return self.ident(x) + + def vval_ushort(self, x): return self.ident(x) + + def vval_long(self, x): return self.ident(x) + + def vval_ulong(self, x): return self.ident(x) + + def vval_llong(self, x): return self.ident(x) + + def vval_ullong(self, x): return self.ident(x) + + def vval_float(self, x): return self.ident(x) + + def vval_double(self, x): return self.ident(x) + + def vval_char(self, x): return self.ident(x) + + def vval_pchar(self, x): return self.ident(x) + + def vval_pcharc(self, x): return self.ident(x) + + def vval_pint(self, x): return self.ident(x) + + def vval_sizet(self, x): return self.ident(x) + + def vval_hello(self, x): return self.ident(x) + + def vval_myint(self, x): return self.ident(x) + + def vref_bool(self, x): return self.ident(x) + + def vref_schar(self, x): return self.ident(x) + + def vref_uchar(self, x): return self.ident(x) + + def vref_int(self, x): return self.ident(x) + + def vref_uint(self, x): return self.ident(x) + + def vref_short(self, x): return self.ident(x) + + def vref_ushort(self, x): return self.ident(x) + + def vref_long(self, x): return self.ident(x) + + def vref_ulong(self, x): return self.ident(x) + + def vref_llong(self, x): return self.ident(x) + + def vref_ullong(self, x): return self.ident(x) + + def vref_float(self, x): return self.ident(x) + + def vref_double(self, x): return self.ident(x) + + def vref_char(self, x): return self.ident(x) + + def vref_pchar(self, x): return self.ident(x) + + def vref_pcharc(self, x): return self.ident(x) + + def vref_pint(self, x): return self.ident(x) + + def vref_sizet(self, x): return self.ident(x) + + def vref_hello(self, x): return self.ident(x) + + def vref_myint(self, x): return self.ident(x) + pass - def ident(self, x): - return x - - def vval_bool(self, x): return self.ident(x) - def vval_schar(self, x): return self.ident(x) - def vval_uchar(self, x): return self.ident(x) - def vval_int(self, x): return self.ident(x) - def vval_uint(self, x): return self.ident(x) - def vval_short(self, x): return self.ident(x) - def vval_ushort(self, x): return self.ident(x) - def vval_long(self, x): return self.ident(x) - def vval_ulong(self, x): return self.ident(x) - def vval_llong(self, x): return self.ident(x) - def vval_ullong(self, x): return self.ident(x) - def vval_float(self, x): return self.ident(x) - def vval_double(self, x): return self.ident(x) - def vval_char(self, x): return self.ident(x) - def vval_pchar(self, x): return self.ident(x) - def vval_pcharc(self, x): return self.ident(x) - def vval_pint(self, x): return self.ident(x) - def vval_sizet(self, x): return self.ident(x) - def vval_hello(self, x): return self.ident(x) - def vval_myint(self, x): return self.ident(x) - - def vref_bool(self, x): return self.ident(x) - def vref_schar(self, x): return self.ident(x) - def vref_uchar(self, x): return self.ident(x) - def vref_int(self, x): return self.ident(x) - def vref_uint(self, x): return self.ident(x) - def vref_short(self, x): return self.ident(x) - def vref_ushort(self, x): return self.ident(x) - def vref_long(self, x): return self.ident(x) - def vref_ulong(self, x): return self.ident(x) - def vref_llong(self, x): return self.ident(x) - def vref_ullong(self, x): return self.ident(x) - def vref_float(self, x): return self.ident(x) - def vref_double(self, x): return self.ident(x) - def vref_char(self, x): return self.ident(x) - def vref_pchar(self, x): return self.ident(x) - def vref_pcharc(self, x): return self.ident(x) - def vref_pint(self, x): return self.ident(x) - def vref_sizet(self, x): return self.ident(x) - def vref_hello(self, x): return self.ident(x) - def vref_myint(self, x): return self.ident(x) - - pass t = Test() @@ -111,7 +172,7 @@ p = PyTest() # internal call check if t.c_check() != p.c_check(): - raise RuntimeError, "bad director" + raise RuntimeError, "bad director" p.var_bool = p.stc_bool p.var_schar = p.stc_schar @@ -166,63 +227,63 @@ t.v_check() # this value contains a '0' char! if def_namet != 'hola': - print "bad namet", def_namet - raise RuntimeError + print "bad namet", def_namet + raise RuntimeError t.var_namet = def_namet if t.var_namet != def_namet: - print "bad namet", t.var_namet, def_namet - raise RuntimeError + print "bad namet", t.var_namet, def_namet + raise RuntimeError t.var_namet = 'hola' if t.var_namet != 'hola': - print "bad namet", t.var_namet - raise RuntimeError + print "bad namet", t.var_namet + raise RuntimeError t.var_namet = 'hol' if t.var_namet != 'hol': -#if t.var_namet != 'hol\0\0': - print "bad namet", t.var_namet - raise RuntimeError + # if t.var_namet != 'hol\0\0': + print "bad namet", t.var_namet + raise RuntimeError cvar.var_char = '\0' if cvar.var_char != '\0': - raise RuntimeError, "bad char '0' case" - + raise RuntimeError, "bad char '0' case" + cvar.var_char = 0 if cvar.var_char != '\0': - raise RuntimeError, "bad char '0' case" + raise RuntimeError, "bad char '0' case" cvar.var_namet = '\0' -#if cvar.var_namet != '\0\0\0\0\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" + print 'hola', '', cvar.var_namet + raise RuntimeError, "bad char '\0' case" cvar.var_namet = '' -#if cvar.var_namet != '\0\0\0\0\0': +# if cvar.var_namet != '\0\0\0\0\0': if cvar.var_namet != '': - raise RuntimeError, "bad char empty case" + raise RuntimeError, "bad char empty case" cvar.var_pchar = None if cvar.var_pchar != None: - raise RuntimeError, "bad None case" + raise RuntimeError, "bad None case" cvar.var_pchar = '' if cvar.var_pchar != '': - print '%c' % (cvar.var_pchar[0],) - raise RuntimeError, "bad char empty case" + print '%c' % (cvar.var_pchar[0],) + raise RuntimeError, "bad char empty case" cvar.var_pcharc = None if cvar.var_pcharc != None: - raise RuntimeError, "bad None case" + raise RuntimeError, "bad None case" cvar.var_pcharc = '' if cvar.var_pcharc != '': - raise RuntimeError, "bad char empty case" + raise RuntimeError, "bad char empty case" # @@ -238,13 +299,13 @@ pchar_setitem(pc, 4, 0) cvar.var_pchar = pc if cvar.var_pchar != "hola": - print cvar.var_pchar - raise RuntimeError, "bad pointer case" + print cvar.var_pchar + raise RuntimeError, "bad pointer case" cvar.var_namet = pc -#if cvar.var_namet != "hola\0": +# if cvar.var_namet != "hola\0": if cvar.var_namet != "hola": - raise RuntimeError, "bad pointer case" + raise RuntimeError, "bad pointer case" delete_pchar(pc) @@ -254,125 +315,124 @@ delete_pchar(pc) try: - error = 0 - a = t.var_uchar - t.var_uchar = 10000 - error = 1 -except OverflowError: - if a != t.var_uchar: + error = 0 + a = t.var_uchar + t.var_uchar = 10000 error = 1 - pass +except OverflowError: + if a != t.var_uchar: + error = 1 + pass if error: - raise RuntimeError, "bad uchar typemap" - + raise RuntimeError, "bad uchar typemap" try: - error = 0 - a = t.var_char - t.var_char = '23' - error = 1 + error = 0 + a = t.var_char + t.var_char = '23' + error = 1 except TypeError: - if a != t.var_char: - error = 1 - pass + if a != t.var_char: + error = 1 + pass if error: - raise RuntimeError, "bad char typemap" + raise RuntimeError, "bad char typemap" try: - error = 0 - a = t.var_ushort - t.var_ushort = -1 - error = 1 -except OverflowError: - if a != t.var_ushort: + error = 0 + a = t.var_ushort + t.var_ushort = -1 error = 1 - pass +except OverflowError: + if a != t.var_ushort: + error = 1 + pass if error: - raise RuntimeError, "bad ushort typemap" + raise RuntimeError, "bad ushort typemap" try: - error = 0 - a = t.var_uint - t.var_uint = -1 - error = 1 -except OverflowError: - if a != t.var_uint: + error = 0 + a = t.var_uint + t.var_uint = -1 error = 1 - pass +except OverflowError: + if a != t.var_uint: + error = 1 + pass if error: - raise RuntimeError, "bad uint typemap" + raise RuntimeError, "bad uint typemap" try: - error = 0 - a = t.var_sizet - t.var_sizet = -1 - error = 1 -except OverflowError: - if a != t.var_sizet: + error = 0 + a = t.var_sizet + t.var_sizet = -1 error = 1 - pass +except OverflowError: + if a != t.var_sizet: + error = 1 + pass if error: - raise RuntimeError, "bad sizet typemap" + raise RuntimeError, "bad sizet typemap" try: - error = 0 - a = t.var_ulong - t.var_ulong = -1 - error = 1 -except OverflowError: - if a != t.var_ulong: + error = 0 + a = t.var_ulong + t.var_ulong = -1 error = 1 - pass +except OverflowError: + if a != t.var_ulong: + error = 1 + pass if error: - raise RuntimeError, "bad ulong typemap" + raise RuntimeError, "bad ulong typemap" # # try: - error = 0 - a = t.var_namet - t.var_namet = '123456' - error = 1 -except TypeError: - if a != t.var_namet: + error = 0 + a = t.var_namet + t.var_namet = '123456' error = 1 - pass +except TypeError: + if a != t.var_namet: + error = 1 + pass if error: - raise RuntimeError, "bad namet typemap" + raise RuntimeError, "bad namet typemap" # # # t2 = p.vtest(t) -if t.var_namet != t2.var_namet: - raise RuntimeError, "bad SWIGTYPE* typemap" - +if t.var_namet != t2.var_namet: + raise RuntimeError, "bad SWIGTYPE* typemap" + if cvar.fixsize != 'ho\0la\0\0\0': - raise RuntimeError, "bad FIXSIZE typemap" + raise RuntimeError, "bad FIXSIZE typemap" cvar.fixsize = 'ho' if cvar.fixsize != 'ho\0\0\0\0\0\0': - raise RuntimeError, "bad FIXSIZE typemap" + raise RuntimeError, "bad FIXSIZE typemap" f = Foo(3) f1 = fptr_val(f) f2 = fptr_ref(f) if f1._a != f2._a: - raise RuntimeError, "bad const ptr& typemap" - + raise RuntimeError, "bad const ptr& typemap" -v = char_foo(1,3) -if v !=3: - raise RuntimeError, "bad int typemap" -s = char_foo(1,"hello") -if s !="hello": - raise RuntimeError, "bad char* typemap" - +v = char_foo(1, 3) +if v != 3: + raise RuntimeError, "bad int typemap" -v = SetPos(1,3) -if v !=4: - raise RuntimeError, "bad int typemap" +s = char_foo(1, "hello") +if s != "hello": + raise RuntimeError, "bad char* typemap" + + +v = SetPos(1, 3) +if v != 4: + raise RuntimeError, "bad int typemap" diff --git a/Examples/test-suite/python/profiletest_runme.py b/Examples/test-suite/python/profiletest_runme.py index d4f07dc11..1e5851e88 100644 --- a/Examples/test-suite/python/profiletest_runme.py +++ b/Examples/test-suite/python/profiletest_runme.py @@ -1,5 +1,5 @@ -import _profiletest -import profiletest +import _profiletest +import profiletest a = profiletest.A() print a @@ -9,24 +9,24 @@ b = profiletest.B() fn = b.fn i = 50000 while i: - a = fn(a) #1 - a = fn(a) #2 - a = fn(a) #3 - a = fn(a) #4 - a = fn(a) #5 - a = fn(a) #6 - a = fn(a) #7 - a = fn(a) #8 - a = fn(a) #9 - a = fn(a) #10 - a = fn(a) #1 - a = fn(a) #2 - a = fn(a) #3 - a = fn(a) #4 - a = fn(a) #5 - a = fn(a) #6 - a = fn(a) #7 - a = fn(a) #8 - a = fn(a) #9 - a = fn(a) #20 - i -= 1 + a = fn(a) # 1 + a = fn(a) # 2 + a = fn(a) # 3 + a = fn(a) # 4 + a = fn(a) # 5 + a = fn(a) # 6 + a = fn(a) # 7 + a = fn(a) # 8 + a = fn(a) # 9 + a = fn(a) # 10 + a = fn(a) # 1 + a = fn(a) # 2 + a = fn(a) # 3 + a = fn(a) # 4 + a = fn(a) # 5 + a = fn(a) # 6 + a = fn(a) # 7 + a = fn(a) # 8 + a = fn(a) # 9 + a = fn(a) # 20 + i -= 1 diff --git a/Examples/test-suite/python/profiletestc_runme.py b/Examples/test-suite/python/profiletestc_runme.py index 33461e484..fe64f969a 100644 --- a/Examples/test-suite/python/profiletestc_runme.py +++ b/Examples/test-suite/python/profiletestc_runme.py @@ -1,54 +1,54 @@ -import _profiletest -#import profiletest +import _profiletest +#import profiletest pa = _profiletest.new_A() -pb = _profiletest.new_B() +pb = _profiletest.new_B() fn = _profiletest.B_fn destroy = _profiletest.delete_A i = 50000 a = pa while i: - a = fn(pb,a) #1 - destroy(a) - a = fn(pb,a) #2 - destroy(a) - a = fn(pb,a) #3 - destroy(a) - a = fn(pb,a) #4 - destroy(a) - a = fn(pb,a) #5 - destroy(a) - a = fn(pb,a) #6 - destroy(a) - a = fn(pb,a) #7 - destroy(a) - a = fn(pb,a) #8 - destroy(a) - a = fn(pb,a) #9 - destroy(a) - a = fn(pb,a) #10 - destroy(a) - a = fn(pb,a) #1 - destroy(a) - a = fn(pb,a) #2 - destroy(a) - a = fn(pb,a) #3 - destroy(a) - a = fn(pb,a) #4 - destroy(a) - a = fn(pb,a) #5 - destroy(a) - a = fn(pb,a) #6 - destroy(a) - a = fn(pb,a) #7 - destroy(a) - a = fn(pb,a) #8 - destroy(a) - a = fn(pb,a) #9 - destroy(a) - a = fn(pb,a) #20 - destroy(a) - i -= 1 + a = fn(pb, a) # 1 + destroy(a) + a = fn(pb, a) # 2 + destroy(a) + a = fn(pb, a) # 3 + destroy(a) + a = fn(pb, a) # 4 + destroy(a) + a = fn(pb, a) # 5 + destroy(a) + a = fn(pb, a) # 6 + destroy(a) + a = fn(pb, a) # 7 + destroy(a) + a = fn(pb, a) # 8 + destroy(a) + a = fn(pb, a) # 9 + destroy(a) + a = fn(pb, a) # 10 + destroy(a) + a = fn(pb, a) # 1 + destroy(a) + a = fn(pb, a) # 2 + destroy(a) + a = fn(pb, a) # 3 + destroy(a) + a = fn(pb, a) # 4 + destroy(a) + a = fn(pb, a) # 5 + destroy(a) + a = fn(pb, a) # 6 + destroy(a) + a = fn(pb, a) # 7 + destroy(a) + a = fn(pb, a) # 8 + destroy(a) + a = fn(pb, a) # 9 + destroy(a) + a = fn(pb, a) # 20 + destroy(a) + i -= 1 _profiletest.delete_A(pa) _profiletest.delete_B(pb) diff --git a/Examples/test-suite/python/python_abstractbase_runme3.py b/Examples/test-suite/python/python_abstractbase_runme3.py index 9b189964d..b4a20f085 100644 --- a/Examples/test-suite/python/python_abstractbase_runme3.py +++ b/Examples/test-suite/python/python_abstractbase_runme3.py @@ -4,7 +4,7 @@ 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) + exit(0) assert issubclass(Mapii, MutableMapping) assert issubclass(Multimapii, MutableMapping) @@ -19,4 +19,3 @@ intset = IntSet() intmultiset = IntMultiset() intvector = IntVector() intlist = IntList() - diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py index 15b0297e9..2f6d94d9c 100644 --- a/Examples/test-suite/python/python_append_runme.py +++ b/Examples/test-suite/python/python_append_runme.py @@ -1,22 +1,22 @@ from python_append import * + def is_new_style_class(cls): - return hasattr(cls, "__class__") + return hasattr(cls, "__class__") # test not relevant for -builtin if is_python_builtin(): - exit(0) + exit(0) -t=Test() +t = Test() t.func() if is_new_style_class(Test): - t.static_func() + t.static_func() else: - Test_static_func() + Test_static_func() if grabpath() != os.path.dirname(mypath): - raise RuntimeError("grabpath failed") + raise RuntimeError("grabpath failed") if grabstaticpath() != os.path.basename(mypath): - raise RuntimeError("grabstaticpath failed") - + raise RuntimeError("grabstaticpath failed") diff --git a/Examples/test-suite/python/python_nondynamic_runme.py b/Examples/test-suite/python/python_nondynamic_runme.py index b860ba0d7..6a430961e 100644 --- a/Examples/test-suite/python/python_nondynamic_runme.py +++ b/Examples/test-suite/python/python_nondynamic_runme.py @@ -5,42 +5,44 @@ aa = python_nondynamic.A() aa.a = 1 aa.b = 2 try: - aa.c = 2 - err = 0 + aa.c = 2 + err = 0 except: - err = 1 + err = 1 + +if not err: + raise RuntimeError, "A is not static" -if not err: - raise RuntimeError, "A is not static" class B(python_nondynamic.A): - c = 4 - def __init__(self): - python_nondynamic.A.__init__(self) + c = 4 + + def __init__(self): + python_nondynamic.A.__init__(self) + pass pass - pass bb = B() try: - bb.c = 3 - err = 0 + bb.c = 3 + err = 0 except: - err = 1 + err = 1 if not err: - print "bb.c = %d" % bb.c - print "B.c = %d" % B.c - raise RuntimeError, "B.c class variable messes up nondynamic-ness of B" + print "bb.c = %d" % bb.c + print "B.c = %d" % B.c + raise RuntimeError, "B.c class variable messes up nondynamic-ness of B" try: - bb.d = 2 - err = 0 + bb.d = 2 + err = 0 except: - err = 1 + err = 1 + +if not err: + raise RuntimeError, "B is not static" -if not err: - raise RuntimeError, "B is not static" - cc = python_nondynamic.C() cc.d = 3 diff --git a/Examples/test-suite/python/python_overload_simple_cast_runme.py b/Examples/test-suite/python/python_overload_simple_cast_runme.py index 1b3a5482c..79ef6cd2e 100644 --- a/Examples/test-suite/python/python_overload_simple_cast_runme.py +++ b/Examples/test-suite/python/python_overload_simple_cast_runme.py @@ -1,16 +1,20 @@ from python_overload_simple_cast import * + class Ai: - def __init__(self,x): + + def __init__(self, x): self.x = x - + def __int__(self): return self.x + class Ad: - def __init__(self,x): + + def __init__(self, x): self.x = x - + def __float__(self): return self.x @@ -26,7 +30,7 @@ except: good = 1 if not good: - raise RuntimeError, "fint(int)" + raise RuntimeError, "fint(int)" if fint(ad) != "fint:int": @@ -40,7 +44,7 @@ if fint(ai) != "fint:int": if fint(5.0) != "fint:int": raise RuntimeError, "fint(int)" - + if fint(3) != "fint:int": raise RuntimeError, "fint(int)" if fint(3.0) != "fint:int": @@ -53,20 +57,19 @@ if fdouble(3) != "fdouble:double": if fdouble(3.0) != "fdouble:double": raise RuntimeError, "fdouble(double)" -if fid(3,3.0) != "fid:intdouble": +if fid(3, 3.0) != "fid:intdouble": raise RuntimeError, "fid:intdouble" -if fid(3.0,3) != "fid:doubleint": +if fid(3.0, 3) != "fid:doubleint": raise RuntimeError, "fid:doubleint" -if fid(ad,ai) != "fid:doubleint": +if fid(ad, ai) != "fid:doubleint": raise RuntimeError, "fid:doubleint" -if fid(ai,ad) != "fid:intdouble": +if fid(ai, ad) != "fid:intdouble": raise RuntimeError, "fid:intdouble" - if foo(3) != "foo:int": raise RuntimeError, "foo(int)" @@ -137,7 +140,7 @@ if s.type != "none": s = Spam(3) if s.type != "int": raise RuntimeError, "Spam(int)" - + s = Spam(3.4) if s.type != "double": raise RuntimeError, "Spam(double)" @@ -160,7 +163,7 @@ if s.type != "void *": # unsigned long long -ullmax = 9223372036854775807 #0xffffffffffffffff +ullmax = 9223372036854775807 # 0xffffffffffffffff ullmaxd = 9007199254740992.0 ullmin = 0 ullmind = 0.0 @@ -174,7 +177,7 @@ if ull(ullmaxd) != ullmaxd: raise RuntimeError, "ull(ullmaxd)" # long long -llmax = 9223372036854775807 #0x7fffffffffffffff +llmax = 9223372036854775807 # 0x7fffffffffffffff llmin = -9223372036854775808 # these are near the largest floats we can still convert into long long llmaxd = 9007199254740992.0 diff --git a/Examples/test-suite/python/python_pybuf_runme3.py b/Examples/test-suite/python/python_pybuf_runme3.py index 152aecdc0..4e57b69e8 100644 --- a/Examples/test-suite/python/python_pybuf_runme3.py +++ b/Examples/test-suite/python/python_pybuf_runme3.py @@ -1,42 +1,41 @@ -#run: +# run: # python python_pybuf_runme3.py benchmark -#for the benchmark, other wise the test case will be run +# for the benchmark, other wise the test case will be run import python_pybuf import sys -if len(sys.argv)>=2 and sys.argv[1]=="benchmark": - #run the benchmark +if len(sys.argv) >= 2 and sys.argv[1] == "benchmark": + # run the benchmark import time - k=1000000 #number of times to excute the functions + k = 1000000 # number of times to excute the functions - t=time.time() + t = time.time() a = bytearray(b'hello world') for i in range(k): - pybuf.title1(a) - print("Time used by bytearray:",time.time()-t) + pybuf.title1(a) + print("Time used by bytearray:", time.time() - t) - t=time.time() + t = time.time() b = 'hello world' for i in range(k): - pybuf.title2(b) - print("Time used by string:",time.time()-t) + pybuf.title2(b) + print("Time used by string:", time.time() - t) else: - #run the test case + # run the test case buf1 = bytearray(10) buf2 = bytearray(50) pybuf.func1(buf1) - assert buf1 == b'a'*10 + assert buf1 == b'a' * 10 pybuf.func2(buf2) assert buf2.startswith(b"Hello world!\x00") count = pybuf.func3(buf2) - assert count==10 #number of alpha and number in 'Hello world!' + assert count == 10 # number of alpha and number in 'Hello world!' length = pybuf.func4(buf2) - assert length==12 + assert length == 12 buf3 = bytearray(b"hello") pybuf.title1(buf3) - assert buf3==b'Hello' - + assert buf3 == b'Hello' diff --git a/Examples/test-suite/python/python_richcompare_runme.py b/Examples/test-suite/python/python_richcompare_runme.py index e077989cc..a68da2f98 100644 --- a/Examples/test-suite/python/python_richcompare_runme.py +++ b/Examples/test-suite/python/python_richcompare_runme.py @@ -11,90 +11,96 @@ b2 = python_richcompare.SubClassB(2) b3 = python_richcompare.SubClassB(3) # Check == and != within a single type -#------------------------------------------------------------------------------- +#------------------------------------------------------------------------- -if not (base1 == base1) : +if not (base1 == base1): raise RuntimeError("Object not == to itself") -if not (base1 == python_richcompare.BaseClass(1)) : +if not (base1 == python_richcompare.BaseClass(1)): raise RuntimeError("Object not == to an equivalent object") -if (base1 == base2) : - raise RuntimeError("Comparing non-equivalent objects of the same type, == returned True") +if (base1 == base2): + raise RuntimeError( + "Comparing non-equivalent objects of the same type, == returned True") -if (base1 != base1) : +if (base1 != base1): raise RuntimeError("Object is != itself") -if (base1 != python_richcompare.BaseClass(1)) : +if (base1 != python_richcompare.BaseClass(1)): raise RuntimeError("Object is != an equivalent object") -if not (base1 != base2) : - raise RuntimeError("Comparing non-equivalent objects of the same type, != returned False") +if not (base1 != base2): + raise RuntimeError( + "Comparing non-equivalent objects of the same type, != returned False") # Check redefined operator== in SubClassA -#------------------------------------------------------------------------------- +#------------------------------------------------------------------------- -if (a2 == base2) : +if (a2 == base2): raise RuntimeError("Redefined operator== in SubClassA failed") -if (a2 == b2) : +if (a2 == b2): raise RuntimeError("Redefined operator== in SubClassA failed") -if not (a1 == a2) : +if not (a1 == a2): raise RuntimeError("Redefined operator== in SubClassA failed") # Check up-casting of subclasses -#------------------------------------------------------------------------------- +#------------------------------------------------------------------------- -if (base2 != a2) : - raise RuntimeError("Comparing equivalent base and subclass instances, != returned True") +if (base2 != a2): + raise RuntimeError( + "Comparing equivalent base and subclass instances, != returned True") -if (a2 == base2) : - raise RuntimeError("Comparing non-equivalent base and subclass instances, == returned True") +if (a2 == base2): + raise RuntimeError( + "Comparing non-equivalent base and subclass instances, == returned True") -if (a1 == b1) : - raise RuntimeError("Comparing equivalent instances of different subclasses, == returned True") +if (a1 == b1): + raise RuntimeError( + "Comparing equivalent instances of different subclasses, == returned True") + +if (b1 == a1): + raise RuntimeError( + "Comparing equivalent instances of different subclasses, == returned True") -if (b1 == a1) : - raise RuntimeError("Comparing equivalent instances of different subclasses, == returned True") - # Check inequalities -#------------------------------------------------------------------------------- +#------------------------------------------------------------------------- -if (a2 > b2) : +if (a2 > b2): raise RuntimeError("operator> failed") -if (a2 < b2) : +if (a2 < b2): raise RuntimeError("operator< failed") -if not (a2 >= b2) : +if not (a2 >= b2): raise RuntimeError("operator>= failed") -if not (a2 <= b2) : +if not (a2 <= b2): raise RuntimeError("operator<= failed") # Check inequalities used for ordering -#------------------------------------------------------------------------------- +#------------------------------------------------------------------------- x = sorted([a2, a3, a1]) -if not (x[0] is a1) : +if not (x[0] is a1): raise RuntimeError("Ordering failed") -if not (x[1] is a2) : +if not (x[1] is a2): raise RuntimeError("Ordering failed") -if not (x[2] is a3) : +if not (x[2] is a3): raise RuntimeError("Ordering failed") x = sorted([base2, a3, b1]) -if not (x[0] is b1) : +if not (x[0] is b1): raise RuntimeError("Ordering failed") -if not (x[1] is base2) : +if not (x[1] is base2): raise RuntimeError("Ordering failed") -if not (x[2] is a3) : +if not (x[2] is a3): raise RuntimeError("Ordering failed") diff --git a/Examples/test-suite/python/python_threads_runme.py b/Examples/test-suite/python/python_threads_runme.py index d00e2458f..74cd0552b 100644 --- a/Examples/test-suite/python/python_threads_runme.py +++ b/Examples/test-suite/python/python_threads_runme.py @@ -3,8 +3,9 @@ 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 + 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/python_varargs_typemap_runme.py b/Examples/test-suite/python/python_varargs_typemap_runme.py index 65be757c8..f3a70e825 100644 --- a/Examples/test-suite/python/python_varargs_typemap_runme.py +++ b/Examples/test-suite/python/python_varargs_typemap_runme.py @@ -1,7 +1,7 @@ import python_varargs_typemap -if (python_varargs_typemap.testfunc(1, 2.0, "three") != "three") : +if (python_varargs_typemap.testfunc(1, 2.0, "three") != "three"): raise RuntimeError("testfunc failed!") -if (python_varargs_typemap.testfunc(1, 2.0, "three", "four", "five") != "threefourfive") : +if (python_varargs_typemap.testfunc(1, 2.0, "three", "four", "five") != "threefourfive"): raise RuntimeError("testfunc failed! {}") diff --git a/Examples/test-suite/python/refcount_runme.py b/Examples/test-suite/python/refcount_runme.py index ca15e04ac..2cab6a77e 100644 --- a/Examples/test-suite/python/refcount_runme.py +++ b/Examples/test-suite/python/refcount_runme.py @@ -8,16 +8,15 @@ b1 = B(a) b2 = B_create(a) - if a.ref_count() != 3: - raise RuntimeError("Count = %d" % a.ref_count()) + raise RuntimeError("Count = %d" % a.ref_count()) rca = b2.get_rca() b3 = B_create(rca) if a.ref_count() != 5: - raise RuntimeError("Count = %d" % a.ref_count()) + raise RuntimeError("Count = %d" % a.ref_count()) v = vector_A(2) @@ -28,28 +27,28 @@ x = v[0] del v if a.ref_count() != 6: - raise RuntimeError("Count = %d" % a.ref_count()) + raise RuntimeError("Count = %d" % a.ref_count()) # Check %newobject b4 = b2.cloner() if b4.ref_count() != 1: - raise RuntimeError + raise RuntimeError b5 = global_create(a) if b5.ref_count() != 1: - raise RuntimeError + raise RuntimeError b6 = Factory_create(a) if b6.ref_count() != 1: - raise RuntimeError + raise RuntimeError b7 = Factory().create2(a) if b7.ref_count() != 1: - raise RuntimeError + raise RuntimeError if a.ref_count() != 10: - raise RuntimeError("Count = %d" % a.ref_count()) + raise RuntimeError("Count = %d" % a.ref_count()) del b4 del b5 @@ -57,5 +56,4 @@ del b6 del b7 if a.ref_count() != 6: - raise RuntimeError("Count = %d" % a.ref_count()) - + raise RuntimeError("Count = %d" % a.ref_count()) diff --git a/Examples/test-suite/python/reference_global_vars_runme.py b/Examples/test-suite/python/reference_global_vars_runme.py index 98aaec5fe..6c2d181ac 100644 --- a/Examples/test-suite/python/reference_global_vars_runme.py +++ b/Examples/test-suite/python/reference_global_vars_runme.py @@ -71,4 +71,3 @@ if value_double(cvar.var_double) != 10.5: cvar.var_TestClass = createref_TestClass(TestClass(20)) if value_TestClass(cvar.var_TestClass).num != 20: raise RuntimeError - diff --git a/Examples/test-suite/python/rename_pcre_encoder_runme.py b/Examples/test-suite/python/rename_pcre_encoder_runme.py index 419acd1a1..aa60e4b18 100644 --- a/Examples/test-suite/python/rename_pcre_encoder_runme.py +++ b/Examples/test-suite/python/rename_pcre_encoder_runme.py @@ -10,7 +10,7 @@ a = AnotherWidget() a.DoSomething() evt = wxEVTSomeEvent() -t = xUnchangedName() +t = xUnchangedName() if StartINSAneAndUNSAvoryTraNSAtlanticRaNSAck() != 42: raise RuntimeError("Unexpected result of renamed function call") diff --git a/Examples/test-suite/python/rename_predicates_runme.py b/Examples/test-suite/python/rename_predicates_runme.py index 2ce097737..2ace8274c 100644 --- a/Examples/test-suite/python/rename_predicates_runme.py +++ b/Examples/test-suite/python/rename_predicates_runme.py @@ -8,22 +8,22 @@ r.MF_extend_function_after() GF_global_function() if r.MV_member_variable != 123: - raise RuntimeError("variable wrong") -r.MV_member_variable = 1234; + raise RuntimeError("variable wrong") +r.MV_member_variable = 1234 if r.MV_member_variable != 1234: - raise RuntimeError("variable wrong") + raise RuntimeError("variable wrong") if cvar.RenamePredicates_MV_static_member_variable != 456: - raise RuntimeError("variable wrong") -cvar.RenamePredicates_MV_static_member_variable = 4567; + raise RuntimeError("variable wrong") +cvar.RenamePredicates_MV_static_member_variable = 4567 if cvar.RenamePredicates_MV_static_member_variable != 4567: - raise RuntimeError("variable wrong") + raise RuntimeError("variable wrong") if cvar.GV_global_variable != 789: - raise RuntimeError("variable wrong") -cvar.GV_global_variable = 7890; + raise RuntimeError("variable wrong") +cvar.GV_global_variable = 7890 if cvar.GV_global_variable != 7890: - raise RuntimeError("variable wrong") + raise RuntimeError("variable wrong") UC_UPPERCASE() LC_lowercase() diff --git a/Examples/test-suite/python/rename_strip_encoder_runme.py b/Examples/test-suite/python/rename_strip_encoder_runme.py index 64be611d6..010c14246 100644 --- a/Examples/test-suite/python/rename_strip_encoder_runme.py +++ b/Examples/test-suite/python/rename_strip_encoder_runme.py @@ -3,4 +3,3 @@ from rename_strip_encoder import * s = SomeWidget() a = AnotherWidget() a.DoSomething() - diff --git a/Examples/test-suite/python/return_const_value_runme.py b/Examples/test-suite/python/return_const_value_runme.py index 932c4822c..947102840 100644 --- a/Examples/test-suite/python/return_const_value_runme.py +++ b/Examples/test-suite/python/return_const_value_runme.py @@ -3,10 +3,10 @@ import sys p = return_const_value.Foo_ptr_getPtr() if (p.getVal() != 17): - print "Runtime test1 faild. p.getVal()=", p.getVal() - sys.exit(1) + print "Runtime test1 faild. p.getVal()=", p.getVal() + sys.exit(1) p = return_const_value.Foo_ptr_getConstPtr() if (p.getVal() != 17): - print "Runtime test2 faild. p.getVal()=", p.getVal() - sys.exit(1) + print "Runtime test2 faild. p.getVal()=", p.getVal() + sys.exit(1) 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 098e5b4c3..9cec1da9f 100644 --- a/Examples/test-suite/python/smart_pointer_const_overload_runme.py +++ b/Examples/test-suite/python/smart_pointer_const_overload_runme.py @@ -3,115 +3,116 @@ from smart_pointer_const_overload import * CONST_ACCESS = 1 MUTABLE_ACCESS = 2 + def test(b, f): - if f.x != 0: - raise RuntimeError + if f.x != 0: + raise RuntimeError - # Test member variable get - if b.x != 0: - raise RuntimeError - - if f.access != CONST_ACCESS: - raise RuntimeError + # Test member variable get + if b.x != 0: + raise RuntimeError - # Test member variable set - b.x = 1 + if f.access != CONST_ACCESS: + raise RuntimeError - if f.x != 1: - raise RuntimeError - - if f.access != MUTABLE_ACCESS: - raise RuntimeError - - # Test const method - if b.getx() != 1: - raise RuntimeError - - if f.access != CONST_ACCESS: - raise RuntimeError - - # Test mutable method - b.setx(2) + # Test member variable set + b.x = 1 - if f.x != 2: - raise RuntimeError - - if f.access != MUTABLE_ACCESS: - raise RuntimeError - - # Test extended const method - if b.getx2() != 2: - raise RuntimeError - - if f.access != CONST_ACCESS: - raise RuntimeError - - # Test extended mutable method - b.setx2(3) + if f.x != 1: + raise RuntimeError - if f.x != 3: - raise RuntimeError - - if f.access != MUTABLE_ACCESS: - raise RuntimeError - - # Test static method - b.statMethod() + if f.access != MUTABLE_ACCESS: + raise RuntimeError - if f.access != CONST_ACCESS: - raise RuntimeError + # Test const method + if b.getx() != 1: + raise RuntimeError - # Test const member - f.access = MUTABLE_ACCESS - - if b.y != 0: - raise RuntimeError - - if f.access != CONST_ACCESS: - raise RuntimeError - - # Test get through mutable pointer to const member - f.access = MUTABLE_ACCESS - - if get_int(b.yp) != 0: - raise RuntimeError - - if f.access != CONST_ACCESS: - raise RuntimeError + if f.access != CONST_ACCESS: + raise RuntimeError - # Test get through const pointer to mutable member - f.x = 4 - f.access = MUTABLE_ACCESS - - if get_int(b.xp) != 4: - raise RuntimeError - - if f.access != CONST_ACCESS: - raise RuntimeError - - # Test set through const pointer to mutable member - f.access = MUTABLE_ACCESS - set_int(b.xp, 5) - - if f.x != 5: - raise RuntimeError - - if f.access != CONST_ACCESS: - raise RuntimeError + # Test mutable method + b.setx(2) - # Test set pointer to const member - b.yp = new_int(6) - - if f.y != 0: - raise RuntimeError - - if get_int(f.yp) != 6: - raise RuntimeError - - if f.access != MUTABLE_ACCESS: - raise RuntimeError - - delete_int(f.yp); + if f.x != 2: + raise RuntimeError + + if f.access != MUTABLE_ACCESS: + raise RuntimeError + + # Test extended const method + if b.getx2() != 2: + raise RuntimeError + + if f.access != CONST_ACCESS: + raise RuntimeError + + # Test extended mutable method + b.setx2(3) + + if f.x != 3: + raise RuntimeError + + if f.access != MUTABLE_ACCESS: + raise RuntimeError + + # Test static method + b.statMethod() + + if f.access != CONST_ACCESS: + raise RuntimeError + + # Test const member + f.access = MUTABLE_ACCESS + + if b.y != 0: + raise RuntimeError + + if f.access != CONST_ACCESS: + raise RuntimeError + + # Test get through mutable pointer to const member + f.access = MUTABLE_ACCESS + + if get_int(b.yp) != 0: + raise RuntimeError + + if f.access != CONST_ACCESS: + raise RuntimeError + + # Test get through const pointer to mutable member + f.x = 4 + f.access = MUTABLE_ACCESS + + if get_int(b.xp) != 4: + raise RuntimeError + + if f.access != CONST_ACCESS: + raise RuntimeError + + # Test set through const pointer to mutable member + f.access = MUTABLE_ACCESS + set_int(b.xp, 5) + + if f.x != 5: + raise RuntimeError + + if f.access != CONST_ACCESS: + raise RuntimeError + + # Test set pointer to const member + b.yp = new_int(6) + + if f.y != 0: + raise RuntimeError + + if get_int(f.yp) != 6: + raise RuntimeError + + if f.access != MUTABLE_ACCESS: + raise RuntimeError + + delete_int(f.yp) f = Foo() b = Bar(f) diff --git a/Examples/test-suite/python/smart_pointer_extend_runme.py b/Examples/test-suite/python/smart_pointer_extend_runme.py index 969757b4c..0b2525081 100644 --- a/Examples/test-suite/python/smart_pointer_extend_runme.py +++ b/Examples/test-suite/python/smart_pointer_extend_runme.py @@ -4,7 +4,7 @@ f = Foo() b = Bar(f) if b.extension() != f.extension(): - raise RuntimeError + raise RuntimeError b = CBase() @@ -12,14 +12,13 @@ d = CDerived() p = CPtr() if b.bar() != p.bar(): - raise RuntimeError + raise RuntimeError if d.foo() != p.foo(): - raise RuntimeError + raise RuntimeError if b.hello() != p.hello(): - raise RuntimeError - + raise RuntimeError d = DFoo() @@ -27,8 +26,7 @@ d = DFoo() dp = DPtrFoo(d) if d.SExt(1) != dp.SExt(1): - raise RuntimeError + raise RuntimeError if d.Ext(1) != dp.Ext(1): - raise RuntimeError - + raise RuntimeError diff --git a/Examples/test-suite/python/smart_pointer_member_runme.py b/Examples/test-suite/python/smart_pointer_member_runme.py index 2cf3686fc..ce91da2bd 100644 --- a/Examples/test-suite/python/smart_pointer_member_runme.py +++ b/Examples/test-suite/python/smart_pointer_member_runme.py @@ -1,34 +1,29 @@ from smart_pointer_member import * + def is_new_style_class(cls): - return hasattr(cls, "__class__") + return hasattr(cls, "__class__") f = Foo() f.y = 1 if f.y != 1: - raise RuntimeError + raise RuntimeError b = Bar(f) b.y = 2 if f.y != 2: - print f.y - print b.y - raise RuntimeError - -if b.x != f.x: - raise RuntimeError - -if b.z != f.z: - raise RuntimeError - -if is_new_style_class(Bar): # feature not supported in old style classes - if Foo.z == Bar.z: + print f.y + print b.y raise RuntimeError +if b.x != f.x: + raise RuntimeError +if b.z != f.z: + raise RuntimeError - - - +if is_new_style_class(Bar): # feature not supported in old style classes + if Foo.z == Bar.z: + raise RuntimeError diff --git a/Examples/test-suite/python/smart_pointer_multi_runme.py b/Examples/test-suite/python/smart_pointer_multi_runme.py index c17053055..26c22d449 100644 --- a/Examples/test-suite/python/smart_pointer_multi_runme.py +++ b/Examples/test-suite/python/smart_pointer_multi_runme.py @@ -12,4 +12,3 @@ if s.getx() != 3: g.x = 4 if g.getx() != 4: raise RuntimeError - diff --git a/Examples/test-suite/python/smart_pointer_multi_typedef_runme.py b/Examples/test-suite/python/smart_pointer_multi_typedef_runme.py index ebf4c9b09..3014febcd 100644 --- a/Examples/test-suite/python/smart_pointer_multi_typedef_runme.py +++ b/Examples/test-suite/python/smart_pointer_multi_typedef_runme.py @@ -12,4 +12,3 @@ if s.getx() != 3: g.x = 4 if g.getx() != 4: raise RuntimeError - diff --git a/Examples/test-suite/python/smart_pointer_not_runme.py b/Examples/test-suite/python/smart_pointer_not_runme.py index 4c90b376b..69704c4ef 100644 --- a/Examples/test-suite/python/smart_pointer_not_runme.py +++ b/Examples/test-suite/python/smart_pointer_not_runme.py @@ -13,7 +13,7 @@ except: try: x = s.x - print "Error! s.x" + print "Error! s.x" except: pass @@ -25,13 +25,13 @@ except: try: x = b.getx() - print "Error! b.getx()" + print "Error! b.getx()" except: pass try: x = s.getx() - print "Error! s.getx()" + print "Error! s.getx()" except: pass diff --git a/Examples/test-suite/python/smart_pointer_overload_runme.py b/Examples/test-suite/python/smart_pointer_overload_runme.py index c9fd3a5b0..16f6997fe 100644 --- a/Examples/test-suite/python/smart_pointer_overload_runme.py +++ b/Examples/test-suite/python/smart_pointer_overload_runme.py @@ -17,5 +17,3 @@ if b.test(3.5) != 2: raise RuntimeError if b.test("hello") != 3: raise RuntimeError - - diff --git a/Examples/test-suite/python/smart_pointer_rename_runme.py b/Examples/test-suite/python/smart_pointer_rename_runme.py index c6d22273c..785f69e64 100644 --- a/Examples/test-suite/python/smart_pointer_rename_runme.py +++ b/Examples/test-suite/python/smart_pointer_rename_runme.py @@ -9,5 +9,5 @@ if b.test() != 3: if b.ftest1(1) != 1: raise RuntimeError -if b.ftest2(2,3) != 2: +if b.ftest2(2, 3) != 2: raise RuntimeError diff --git a/Examples/test-suite/python/smart_pointer_templatevariables_runme.py b/Examples/test-suite/python/smart_pointer_templatevariables_runme.py index 367dcf3b2..465551480 100644 --- a/Examples/test-suite/python/smart_pointer_templatevariables_runme.py +++ b/Examples/test-suite/python/smart_pointer_templatevariables_runme.py @@ -3,15 +3,14 @@ from smart_pointer_templatevariables import * d = DiffImContainerPtr_D(create(1234, 5678)) if (d.id != 1234): - raise RuntimeError -#if (d.xyz != 5678): + raise RuntimeError +# if (d.xyz != 5678): # raise RuntimeError d.id = 4321 #d.xyz = 8765 if (d.id != 4321): - raise RuntimeError -#if (d.xyz != 8765): + raise RuntimeError +# if (d.xyz != 8765): # raise RuntimeError - diff --git a/Examples/test-suite/python/sneaky1_runme.py b/Examples/test-suite/python/sneaky1_runme.py index 9c2c32f85..c56f56f9e 100644 --- a/Examples/test-suite/python/sneaky1_runme.py +++ b/Examples/test-suite/python/sneaky1_runme.py @@ -1,5 +1,5 @@ import sneaky1 -x = sneaky1.add(3,4) -y = sneaky1.subtract(3,4) -z = sneaky1.mul(3,4) -w = sneaky1.divide(3,4) +x = sneaky1.add(3, 4) +y = sneaky1.subtract(3, 4) +z = sneaky1.mul(3, 4) +w = sneaky1.divide(3, 4) diff --git a/Examples/test-suite/python/special_variable_macros_runme.py b/Examples/test-suite/python/special_variable_macros_runme.py index eaf9c1858..e487f9a50 100644 --- a/Examples/test-suite/python/special_variable_macros_runme.py +++ b/Examples/test-suite/python/special_variable_macros_runme.py @@ -2,17 +2,16 @@ import special_variable_macros name = special_variable_macros.Name() if special_variable_macros.testFred(name) != "none": - raise "test failed" + raise "test failed" if special_variable_macros.testJack(name) != "$specialname": - raise "test failed" + raise "test failed" if special_variable_macros.testJill(name) != "jilly": - raise "test failed" + raise "test failed" if special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap": - raise "test failed" + raise "test failed" if special_variable_macros.testJames(name) != "SWIGTYPE_Name": - raise "test failed" + raise "test failed" if special_variable_macros.testJim(name) != "multiname num": - raise "test failed" + raise "test failed" if special_variable_macros.testJohn(special_variable_macros.PairIntBool(10, False)) != 123: - raise "test failed" - + raise "test failed" diff --git a/Examples/test-suite/python/static_const_member_2_runme.py b/Examples/test-suite/python/static_const_member_2_runme.py index 081726361..01704e39c 100644 --- a/Examples/test-suite/python/static_const_member_2_runme.py +++ b/Examples/test-suite/python/static_const_member_2_runme.py @@ -12,5 +12,5 @@ except: raise RuntimeError -if Foo.BAZ.val != 2*Foo.BAR.val: +if Foo.BAZ.val != 2 * Foo.BAR.val: raise RuntimeError diff --git a/Examples/test-suite/python/std_containers_runme.py b/Examples/test-suite/python/std_containers_runme.py index f90c98405..d4625daa0 100644 --- a/Examples/test-suite/python/std_containers_runme.py +++ b/Examples/test-suite/python/std_containers_runme.py @@ -5,73 +5,72 @@ import std_containers cube = (((1, 2), (3, 4)), ((5, 6), (7, 8))) icube = std_containers.cident(cube) -for i in range(0,len(cube)): - if cube[i] != icube[i]: - raise RuntimeError, "bad cident" +for i in range(0, len(cube)): + if cube[i] != icube[i]: + raise RuntimeError, "bad cident" -p = (1,2) +p = (1, 2) if p != std_containers.pident(p): - raise RuntimeError, "bad pident" + raise RuntimeError, "bad pident" -v = (1,2,3,4,5,6) +v = (1, 2, 3, 4, 5, 6) iv = std_containers.vident(v) -for i in range(0,len(v)): - if v[i] != iv[i]: - raise RuntimeError, "bad vident" - +for i in range(0, len(v)): + if v[i] != iv[i]: + raise RuntimeError, "bad vident" iv = std_containers.videntu(v) -for i in range(0,len(v)): - if v[i] != iv[i]: - raise RuntimeError, "bad videntu" +for i in range(0, len(v)): + if v[i] != iv[i]: + raise RuntimeError, "bad videntu" vu = std_containers.vector_ui(v) if vu[2] != std_containers.videntu(vu)[2]: - raise RuntimeError, "bad videntu" - + raise RuntimeError, "bad videntu" + if v[0:3][1] != vu[0:3][1]: - print v[0:3][1], vu[0:3][1] - raise RuntimeError, "bad getslice" - + print v[0:3][1], vu[0:3][1] + raise RuntimeError, "bad getslice" -m = ((1,2,3),(2,3),(3,4)) + +m = ((1, 2, 3), (2, 3), (3, 4)) im = std_containers.midenti(m) -for i in range(0,len(m)): - for j in range(0,len(m[i])): - if m[i][j] != im[i][j]: - raise RuntimeError, "bad getslice" +for i in range(0, len(m)): + for j in range(0, len(m[i])): + if m[i][j] != im[i][j]: + raise RuntimeError, "bad getslice" -m = ((True,False,True),(True,True),(True,True)) +m = ((True, False, True), (True, True), (True, True)) im = std_containers.midentb(m) -for i in range(0,len(m)): - for j in range(0,len(m[i])): - if m[i][j] != im[i][j]: - raise RuntimeError, "bad getslice" +for i in range(0, len(m)): + for j in range(0, len(m[i])): + if m[i][j] != im[i][j]: + raise RuntimeError, "bad getslice" mi = std_containers.imatrix(m) mc = std_containers.cmatrix(m) if mi[0][1] != mc[0][1]: - raise RuntimeError, "bad matrix" + raise RuntimeError, "bad matrix" -map ={} +map = {} map['hello'] = 1 map['hi'] = 2 map['3'] = 2 imap = std_containers.mapident(map) for k in map: - if map[k] != imap[k]: - raise RuntimeError, "bad map" + if map[k] != imap[k]: + raise RuntimeError, "bad map" -mapc ={} +mapc = {} c1 = std_containers.C() c2 = std_containers.C() mapc[1] = c1.this @@ -80,23 +79,23 @@ mapc[2] = c2 std_containers.mapidentc(mapc) -vi = std_containers.vector_i((2,2,3,4)) +vi = std_containers.vector_i((2, 2, 3, 4)) -v = (1,2) +v = (1, 2) v1 = std_containers.v_inout(vi) vi[1], v1[1] -v1,v2 = ((1,2),(3,4)) -v1,v2 = std_containers.v_inout2(v1,v2) +v1, v2 = ((1, 2), (3, 4)) +v1, v2 = std_containers.v_inout2(v1, v2) a1 = std_containers.A(1) a2 = std_containers.A(2) -p1 = (1,a1) -p2 = (2,a2) -v = (p1,p2) -v2= std_containers.pia_vident(v) +p1 = (1, a1) +p2 = (2, a2) +v = (p1, p2) +v2 = std_containers.pia_vident(v) v2[0][1].a v2[1][1].a @@ -110,10 +109,8 @@ s = std_containers.set_i() s.append(1) s.append(2) s.append(3) -j=1 +j = 1 for i in s: - if i != j: - raise RuntimeError - j = j + 1 - - + if i != j: + raise RuntimeError + j = j + 1 diff --git a/Examples/test-suite/python/struct_initialization_runme.py b/Examples/test-suite/python/struct_initialization_runme.py index fbed6a5e9..524b89630 100644 --- a/Examples/test-suite/python/struct_initialization_runme.py +++ b/Examples/test-suite/python/struct_initialization_runme.py @@ -1,20 +1,19 @@ from struct_initialization import * if cvar.instanceC1.x != 10: - raise RuntimeError + raise RuntimeError if cvar.instanceD1.x != 10: - raise RuntimeError + raise RuntimeError if cvar.instanceD2.x != 20: - raise RuntimeError + raise RuntimeError if cvar.instanceD3.x != 30: - raise RuntimeError + raise RuntimeError if cvar.instanceE1.x != 1: - raise RuntimeError + raise RuntimeError if cvar.instanceF1.x != 1: - raise RuntimeError - + raise RuntimeError diff --git a/Examples/test-suite/python/struct_value_runme.py b/Examples/test-suite/python/struct_value_runme.py index a20e83439..aa3ece38c 100644 --- a/Examples/test-suite/python/struct_value_runme.py +++ b/Examples/test-suite/python/struct_value_runme.py @@ -3,28 +3,32 @@ import struct_value b = struct_value.Bar() b.a.x = 3 -if b.a.x != 3: raise RuntimeError +if b.a.x != 3: + raise RuntimeError b.b.x = 3 -if b.b.x != 3: raise RuntimeError +if b.b.x != 3: + raise RuntimeError # Test dynamically added attributes - Github pull request #320 b.added = 123 if b.added != 123: - raise RuntimeError("Wrong attribute value") + raise RuntimeError("Wrong attribute value") if not b.__dict__.has_key("added"): - raise RuntimeError("Missing added attribute in __dict__") + raise RuntimeError("Missing added attribute in __dict__") + class PyBar(struct_value.Bar): - def __init__(self): - self.extra = "hi" - struct_value.Bar.__init__(self) + + def __init__(self): + self.extra = "hi" + struct_value.Bar.__init__(self) pybar = PyBar() if not pybar.__dict__.has_key("extra"): - raise RuntimeError("Missing extra attribute in __dict__") + raise RuntimeError("Missing extra attribute in __dict__") if pybar.extra != "hi": - raise RuntimeError("Incorrect attribute value for extra") + raise RuntimeError("Incorrect attribute value for extra") diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py index a906108e3..346b05d40 100644 --- a/Examples/test-suite/python/swigobject_runme.py +++ b/Examples/test-suite/python/swigobject_runme.py @@ -1,5 +1,5 @@ -from swigobject import * +from swigobject import * a = A() @@ -8,11 +8,12 @@ a1 = a_ptr(a) a2 = a_ptr(a) if a1.this != a2.this: - raise RuntimeError - + raise RuntimeError + lthis = long(a.this) -# match pointer value, but deal with leading zeros on 8/16 bit systems and different C++ compilers interpretation of %p +# match pointer value, but deal with leading zeros on 8/16 bit systems and +# different C++ compilers interpretation of %p xstr1 = "%016X" % (lthis,) xstr1 = str.lstrip(xstr1, '0') xstr2 = pointer_str(a) @@ -22,8 +23,8 @@ xstr2 = str.lstrip(xstr2, '0') xstr2 = str.upper(xstr2) if xstr1 != xstr2: - print xstr1, xstr2 - raise RuntimeError + print xstr1, xstr2 + raise RuntimeError s = str(a.this) r = repr(a.this) @@ -31,4 +32,4 @@ r = repr(a.this) v1 = v_ptr(a) v2 = v_ptr(a) if long(v1) != long(v2): - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/template_classes_runme.py b/Examples/test-suite/python/template_classes_runme.py index 9c04fee95..38b2d7a62 100644 --- a/Examples/test-suite/python/template_classes_runme.py +++ b/Examples/test-suite/python/template_classes_runme.py @@ -12,33 +12,33 @@ RectangleInt.static_onearg(1) fail = True try: - rectangle.setPoint() + rectangle.setPoint() except TypeError, e: - fail = False + fail = False if fail: - raise RuntimeError("argument count check failed") + raise RuntimeError("argument count check failed") fail = True try: - rectangle.getPoint(0) + rectangle.getPoint(0) except TypeError, e: - fail = False + fail = False if fail: - raise RuntimeError("argument count check failed") + raise RuntimeError("argument count check failed") fail = True try: - RectangleInt.static_noargs(0) + RectangleInt.static_noargs(0) except TypeError, e: - fail = False + fail = False if fail: - raise RuntimeError("argument count check failed") + raise RuntimeError("argument count check failed") fail = True try: - RectangleInt.static_onearg() + RectangleInt.static_onearg() except TypeError, e: - fail = False + fail = False if fail: - raise RuntimeError("argument count check failed") + raise RuntimeError("argument count check failed") diff --git a/Examples/test-suite/python/template_default_arg_runme.py b/Examples/test-suite/python/template_default_arg_runme.py index 235a2313a..91b1e0e8c 100644 --- a/Examples/test-suite/python/template_default_arg_runme.py +++ b/Examples/test-suite/python/template_default_arg_runme.py @@ -7,22 +7,20 @@ helloInt.foo(template_default_arg.Hello_int.hi) x = template_default_arg.X_int() if (x.meth(20.0, 200) != 200): - raise RuntimeError, ("X_int test 1 failed") + raise RuntimeError, ("X_int test 1 failed") if (x.meth(20) != 20): - raise RuntimeError, ("X_int test 2 failed") + raise RuntimeError, ("X_int test 2 failed") if (x.meth() != 0): - raise RuntimeError, ("X_int test 3 failed") - + raise RuntimeError, ("X_int test 3 failed") y = template_default_arg.Y_unsigned() if (y.meth(20.0, 200) != 200): - raise RuntimeError, ("Y_unsigned test 1 failed") + raise RuntimeError, ("Y_unsigned test 1 failed") if (y.meth(20) != 20): - raise RuntimeError, ("Y_unsigned test 2 failed") + raise RuntimeError, ("Y_unsigned test 2 failed") if (y.meth() != 0): - raise RuntimeError, ("Y_unsigned test 3 failed") - + raise RuntimeError, ("Y_unsigned test 3 failed") x = template_default_arg.X_longlong() @@ -37,7 +35,8 @@ x = template_default_arg.X_int(20.0, 200) x = template_default_arg.X_hello_unsigned() x = template_default_arg.X_hello_unsigned(20.0) -x = template_default_arg.X_hello_unsigned(20.0, template_default_arg.Hello_int()) +x = template_default_arg.X_hello_unsigned( + 20.0, template_default_arg.Hello_int()) y = template_default_arg.Y_hello_unsigned() @@ -46,7 +45,6 @@ y.meth(template_default_arg.Hello_int()) y.meth() - fz = template_default_arg.Foo_Z_8() x = template_default_arg.X_Foo_Z_8() fzc = x.meth(fz) @@ -56,43 +54,40 @@ fzc = x.meth(fz) # plain function: int ott(Foo) if (template_default_arg.ott(template_default_arg.Foo_int()) != 30): - raise RuntimeError, ("ott test 1 failed") + raise RuntimeError, ("ott test 1 failed") # %template(ott) ott if (template_default_arg.ott() != 10): - raise RuntimeError, ("ott test 2 failed") + raise RuntimeError, ("ott test 2 failed") if (template_default_arg.ott(1) != 10): - raise RuntimeError, ("ott test 3 failed") + raise RuntimeError, ("ott test 3 failed") if (template_default_arg.ott(1, 1) != 10): - raise RuntimeError, ("ott test 4 failed") + raise RuntimeError, ("ott test 4 failed") if (template_default_arg.ott("hi") != 20): - raise RuntimeError, ("ott test 5 failed") + raise RuntimeError, ("ott test 5 failed") if (template_default_arg.ott("hi", 1) != 20): - raise RuntimeError, ("ott test 6 failed") + raise RuntimeError, ("ott test 6 failed") if (template_default_arg.ott("hi", 1, 1) != 20): - raise RuntimeError, ("ott test 7 failed") + raise RuntimeError, ("ott test 7 failed") # %template(ott) ott if (template_default_arg.ottstring(template_default_arg.Hello_int(), "hi") != 40): - raise RuntimeError, ("ott test 8 failed") + raise RuntimeError, ("ott test 8 failed") if (template_default_arg.ottstring(template_default_arg.Hello_int()) != 40): - raise RuntimeError, ("ott test 9 failed") + raise RuntimeError, ("ott test 9 failed") # %template(ott) ott if (template_default_arg.ottint(template_default_arg.Hello_int(), 1) != 50): - raise RuntimeError, ("ott test 10 failed") + raise RuntimeError, ("ott test 10 failed") if (template_default_arg.ottint(template_default_arg.Hello_int()) != 50): - raise RuntimeError, ("ott test 11 failed") + raise RuntimeError, ("ott test 11 failed") # %template(ott) ott if (template_default_arg.ott(template_default_arg.Hello_int(), 1.0) != 60): - raise RuntimeError, ("ott test 12 failed") + raise RuntimeError, ("ott test 12 failed") if (template_default_arg.ott(template_default_arg.Hello_int()) != 60): - raise RuntimeError, ("ott test 13 failed") - - - + raise RuntimeError, ("ott test 13 failed") diff --git a/Examples/test-suite/python/template_inherit_runme.py b/Examples/test-suite/python/template_inherit_runme.py index bb1465a2b..2c47770a5 100644 --- a/Examples/test-suite/python/template_inherit_runme.py +++ b/Examples/test-suite/python/template_inherit_runme.py @@ -50,4 +50,3 @@ if invoke_blah_uint(e) != "Foo": if invoke_blah_uint(f) != "Bar": raise ValueError - diff --git a/Examples/test-suite/python/template_matrix_runme.py b/Examples/test-suite/python/template_matrix_runme.py index 95815a068..208aafb8e 100644 --- a/Examples/test-suite/python/template_matrix_runme.py +++ b/Examples/test-suite/python/template_matrix_runme.py @@ -1,6 +1,4 @@ -from template_matrix import * -passVector([1,2,3]) -passMatrix([[1,2],[1,2,3]]) -passCube([[[1,2],[1,2,3]],[[1,2],[1,2,3]]]) - - +from template_matrix import * +passVector([1, 2, 3]) +passMatrix([[1, 2], [1, 2, 3]]) +passCube([[[1, 2], [1, 2, 3]], [[1, 2], [1, 2, 3]]]) diff --git a/Examples/test-suite/python/template_ns4_runme.py b/Examples/test-suite/python/template_ns4_runme.py index 81107b493..deef019eb 100644 --- a/Examples/test-suite/python/template_ns4_runme.py +++ b/Examples/test-suite/python/template_ns4_runme.py @@ -1,5 +1,5 @@ from template_ns4 import * -d = make_Class_DD(); +d = make_Class_DD() if d.test() != "test": - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/template_ns_runme.py b/Examples/test-suite/python/template_ns_runme.py index 20cc9b99c..888d125c4 100644 --- a/Examples/test-suite/python/template_ns_runme.py +++ b/Examples/test-suite/python/template_ns_runme.py @@ -1,5 +1,5 @@ from template_ns import * -p1 = pairii(2,3) +p1 = pairii(2, 3) p2 = pairii(p1) if p2.first != 2: @@ -7,7 +7,7 @@ if p2.first != 2: if p2.second != 3: raise RuntimeError -p3 = pairdd(3.5,2.5) +p3 = pairdd(3.5, 2.5) p4 = pairdd(p3) if p4.first != 3.5: diff --git a/Examples/test-suite/python/template_opaque_runme.py b/Examples/test-suite/python/template_opaque_runme.py index f3aeb39d1..6f21116ee 100644 --- a/Examples/test-suite/python/template_opaque_runme.py +++ b/Examples/test-suite/python/template_opaque_runme.py @@ -3,4 +3,3 @@ import template_opaque v = template_opaque.OpaqueVectorType(10) template_opaque.FillVector(v) - diff --git a/Examples/test-suite/python/template_ref_type_runme.py b/Examples/test-suite/python/template_ref_type_runme.py index 0b3e4dd26..f4ebc354c 100644 --- a/Examples/test-suite/python/template_ref_type_runme.py +++ b/Examples/test-suite/python/template_ref_type_runme.py @@ -1,5 +1,5 @@ import template_ref_type xr = template_ref_type.XC() -y = template_ref_type.Y() +y = template_ref_type.Y() y.find(xr) diff --git a/Examples/test-suite/python/template_static_runme.py b/Examples/test-suite/python/template_static_runme.py index 9171d93b5..c87a52439 100644 --- a/Examples/test-suite/python/template_static_runme.py +++ b/Examples/test-suite/python/template_static_runme.py @@ -1,3 +1,3 @@ -from template_static import * +from template_static import * Foo_bar_double(1) diff --git a/Examples/test-suite/python/template_tbase_template_runme.py b/Examples/test-suite/python/template_tbase_template_runme.py index d13c5f2c2..b5f2e31f4 100644 --- a/Examples/test-suite/python/template_tbase_template_runme.py +++ b/Examples/test-suite/python/template_tbase_template_runme.py @@ -2,4 +2,4 @@ from template_tbase_template import * a = make_Class_dd() if a.test() != "test": - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/template_type_namespace_runme.py b/Examples/test-suite/python/template_type_namespace_runme.py index 19ea5f5ce..5f00fe5f2 100644 --- a/Examples/test-suite/python/template_type_namespace_runme.py +++ b/Examples/test-suite/python/template_type_namespace_runme.py @@ -1,5 +1,4 @@ from template_type_namespace import * if type(foo()[0]) != type(""): - raise RuntimeError - + raise RuntimeError diff --git a/Examples/test-suite/python/template_typedef_cplx2_runme.py b/Examples/test-suite/python/template_typedef_cplx2_runme.py index 04c599329..3043d4285 100644 --- a/Examples/test-suite/python/template_typedef_cplx2_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx2_runme.py @@ -5,28 +5,28 @@ from template_typedef_cplx2 import * # try: - d = make_Identity_double() - a = d.this + d = make_Identity_double() + a = d.this except: - print d, "is not an instance" - raise RuntimeError + print d, "is not an instance" + raise RuntimeError s = '%s' % d if str.find(s, 'ArithUnaryFunction') == -1: - print d, "is not an ArithUnaryFunction" - raise RuntimeError + print d, "is not an ArithUnaryFunction" + raise RuntimeError try: - e = make_Multiplies_double_double_double_double(d, d) - a = e.this + e = make_Multiplies_double_double_double_double(d, d) + a = e.this except: - print e, "is not an instance" - raise RuntimeError + print e, "is not an instance" + raise RuntimeError s = '%s' % e if str.find(s, 'ArithUnaryFunction') == -1: - print e, "is not an ArithUnaryFunction" - raise RuntimeError + print e, "is not an ArithUnaryFunction" + raise RuntimeError # @@ -34,61 +34,60 @@ if str.find(s, 'ArithUnaryFunction') == -1: # try: - c = make_Identity_complex() - a = c.this + c = make_Identity_complex() + a = c.this except: - print c, "is not an instance" - raise RuntimeError + print c, "is not an instance" + raise RuntimeError s = '%s' % c if str.find(s, 'ArithUnaryFunction') == -1: - print c, "is not an ArithUnaryFunction" - raise RuntimeError + print c, "is not an ArithUnaryFunction" + raise RuntimeError try: - f = make_Multiplies_complex_complex_complex_complex(c, c) - a = f.this + f = make_Multiplies_complex_complex_complex_complex(c, c) + a = f.this except: - print f, "is not an instance" - raise RuntimeError + print f, "is not an instance" + raise RuntimeError s = '%s' % f if str.find(s, 'ArithUnaryFunction') == -1: - print f, "is not an ArithUnaryFunction" - raise RuntimeError + print f, "is not an ArithUnaryFunction" + raise RuntimeError # # Mix case # try: - g = make_Multiplies_double_double_complex_complex(d, c) - a = g.this + g = make_Multiplies_double_double_complex_complex(d, c) + a = g.this except: - print g, "is not an instance" - raise RuntimeError + print g, "is not an instance" + raise RuntimeError s = '%s' % g if str.find(s, 'ArithUnaryFunction') == -1: - print g, "is not an ArithUnaryFunction" - raise RuntimeError + print g, "is not an ArithUnaryFunction" + raise RuntimeError try: - h = make_Multiplies_complex_complex_double_double(c, d) - a = h.this + h = make_Multiplies_complex_complex_double_double(c, d) + a = h.this except: - print h, "is not an instance" - raise RuntimeError + print h, "is not an instance" + raise RuntimeError s = '%s' % h if str.find(s, 'ArithUnaryFunction') == -1: - print h, "is not an ArithUnaryFunction" - raise RuntimeError + print h, "is not an ArithUnaryFunction" + raise RuntimeError try: - a = g.get_value() + a = g.get_value() except: - print g, "has not get_value() method" - raise RuntimeError - + print g, "has not get_value() method" + raise RuntimeError diff --git a/Examples/test-suite/python/template_typedef_cplx3_runme.py b/Examples/test-suite/python/template_typedef_cplx3_runme.py index b8ac1b6ef..ad361426e 100644 --- a/Examples/test-suite/python/template_typedef_cplx3_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx3_runme.py @@ -11,14 +11,14 @@ s.get_base_value() s.get_value() s.get_arith_value() my_func_r(s) -make_Multiplies_double_double_double_double(s,s) +make_Multiplies_double_double_double_double(s, s) z = CSin() z.get_base_value() z.get_value() z.get_arith_value() my_func_c(z) -make_Multiplies_complex_complex_complex_complex(z,z) +make_Multiplies_complex_complex_complex_complex(z, z) # # Here we fail @@ -28,7 +28,3 @@ my_func_r(d) c = make_Identity_complex() my_func_c(c) - - - - diff --git a/Examples/test-suite/python/template_typedef_cplx4_runme.py b/Examples/test-suite/python/template_typedef_cplx4_runme.py index faeca219f..25ac851fb 100644 --- a/Examples/test-suite/python/template_typedef_cplx4_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx4_runme.py @@ -11,14 +11,14 @@ s.get_base_value() s.get_value() s.get_arith_value() my_func_r(s) -make_Multiplies_double_double_double_double(s,s) +make_Multiplies_double_double_double_double(s, s) z = CSin() z.get_base_value() z.get_value() z.get_arith_value() my_func_c(z) -make_Multiplies_complex_complex_complex_complex(z,z) +make_Multiplies_complex_complex_complex_complex(z, z) # # Here we fail @@ -28,7 +28,3 @@ my_func_r(d) c = make_Identity_complex() my_func_c(c) - - - - diff --git a/Examples/test-suite/python/template_typedef_cplx_runme.py b/Examples/test-suite/python/template_typedef_cplx_runme.py index 2cd9c8348..afb97d070 100644 --- a/Examples/test-suite/python/template_typedef_cplx_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx_runme.py @@ -5,28 +5,28 @@ from template_typedef_cplx import * # try: - d = make_Identity_double() - a = d.this + d = make_Identity_double() + a = d.this except: - print d, "is not an instance" - raise RuntimeError + print d, "is not an instance" + raise RuntimeError s = '%s' % d if str.find(s, 'ArithUnaryFunction') == -1: - print d, "is not an ArithUnaryFunction" - raise RuntimeError + print d, "is not an ArithUnaryFunction" + raise RuntimeError try: - e = make_Multiplies_double_double_double_double(d, d) - a = e.this + e = make_Multiplies_double_double_double_double(d, d) + a = e.this except: - print e, "is not an instance" - raise RuntimeError + print e, "is not an instance" + raise RuntimeError s = '%s' % e if str.find(s, 'ArithUnaryFunction') == -1: - print e, "is not an ArithUnaryFunction" - raise RuntimeError + print e, "is not an ArithUnaryFunction" + raise RuntimeError # @@ -34,54 +34,54 @@ if str.find(s, 'ArithUnaryFunction') == -1: # try: - c = make_Identity_complex() - a = c.this + c = make_Identity_complex() + a = c.this except: - print c, "is not an instance" - raise RuntimeError + print c, "is not an instance" + raise RuntimeError s = '%s' % c if str.find(s, 'ArithUnaryFunction') == -1: - print c, "is not an ArithUnaryFunction" - raise RuntimeError + print c, "is not an ArithUnaryFunction" + raise RuntimeError try: - f = make_Multiplies_complex_complex_complex_complex(c, c) - a = f.this + f = make_Multiplies_complex_complex_complex_complex(c, c) + a = f.this except: - print f, "is not an instance" - raise RuntimeError + print f, "is not an instance" + raise RuntimeError s = '%s' % f if str.find(s, 'ArithUnaryFunction') == -1: - print f, "is not an ArithUnaryFunction" - raise RuntimeError + print f, "is not an ArithUnaryFunction" + raise RuntimeError # # Mix case # try: - g = make_Multiplies_double_double_complex_complex(d, c) - a = g.this + g = make_Multiplies_double_double_complex_complex(d, c) + a = g.this except: - print g, "is not an instance" - raise RuntimeError + print g, "is not an instance" + raise RuntimeError s = '%s' % g if str.find(s, 'ArithUnaryFunction') == -1: - print g, "is not an ArithUnaryFunction" - raise RuntimeError + print g, "is not an ArithUnaryFunction" + raise RuntimeError try: - h = make_Multiplies_complex_complex_double_double(c, d) - a = h.this + h = make_Multiplies_complex_complex_double_double(c, d) + a = h.this except: - print h, "is not an instance" - raise RuntimeError + print h, "is not an instance" + raise RuntimeError s = '%s' % h if str.find(s, 'ArithUnaryFunction') == -1: - print h, "is not an ArithUnaryFunction" - raise RuntimeError + print h, "is not an ArithUnaryFunction" + raise RuntimeError diff --git a/Examples/test-suite/python/template_typedef_import_runme.py b/Examples/test-suite/python/template_typedef_import_runme.py index 5c0b0b936..5da489fea 100644 --- a/Examples/test-suite/python/template_typedef_import_runme.py +++ b/Examples/test-suite/python/template_typedef_import_runme.py @@ -11,14 +11,14 @@ s.get_base_value() s.get_value() s.get_arith_value() my_func_r(s) -make_Multiplies_double_double_double_double(s,s) +make_Multiplies_double_double_double_double(s, s) z = CSin() z.get_base_value() z.get_value() z.get_arith_value() my_func_c(z) -make_Multiplies_complex_complex_complex_complex(z,z) +make_Multiplies_complex_complex_complex_complex(z, z) # # Here we fail @@ -28,7 +28,3 @@ my_func_r(d) c = make_Identity_complex() my_func_c(c) - - - - diff --git a/Examples/test-suite/python/template_typedef_runme.py b/Examples/test-suite/python/template_typedef_runme.py index 4b3970593..16695bada 100644 --- a/Examples/test-suite/python/template_typedef_runme.py +++ b/Examples/test-suite/python/template_typedef_runme.py @@ -5,42 +5,42 @@ c = make_Identity_reald() try: - a = d.this - a = c.this + a = d.this + a = c.this except: - raise RuntimeError + raise RuntimeError try: - e = make_Multiplies_float_float_float_float(d, d) - a = e.this + e = make_Multiplies_float_float_float_float(d, d) + a = e.this except: - print e, "is not an instance" - raise RuntimeError + print e, "is not an instance" + raise RuntimeError try: - f = make_Multiplies_reald_reald_reald_reald(c, c) - a = f.this + f = make_Multiplies_reald_reald_reald_reald(c, c) + a = f.this except: - print f, "is not an instance" - raise RuntimeError + print f, "is not an instance" + raise RuntimeError try: - g = make_Multiplies_float_float_reald_reald(d, c) - a = g.this + g = make_Multiplies_float_float_reald_reald(d, c) + a = g.this except: - print g, "is not an instance" - raise RuntimeError + print g, "is not an instance" + raise RuntimeError # the old large format if not SWIG_TypeQuery("vfncs::ArithUnaryFunction::argument_type,vfncs::arith_traits::result_type > *"): - raise RuntimeError + raise RuntimeError # the reduced format if not SWIG_TypeQuery("vfncs::ArithUnaryFunction *"): - raise RuntimeError + raise RuntimeError # this is a bad name if SWIG_TypeQuery("vfncs::ArithUnaryFunction *"): - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/template_typemaps_typedef2_runme.py b/Examples/test-suite/python/template_typemaps_typedef2_runme.py index 8a66d27d0..258f44366 100644 --- a/Examples/test-suite/python/template_typemaps_typedef2_runme.py +++ b/Examples/test-suite/python/template_typemaps_typedef2_runme.py @@ -13,8 +13,8 @@ m2 = MultimapAInt() #dummy_pair = m2.make_dummy_pair() #val = m2.typemap_test(dummy_pair) -#print val -#if val != 4321: +# print val +# if val != 4321: # raise RuntimeError, "typemaps not working" if typedef_test1(dummy_pair).val != 1234: @@ -34,4 +34,3 @@ if typedef_test5(dummy_pair).val != 1234: if typedef_test6(dummy_pair).val != 1234: raise RuntimeError, "typedef_test6 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 a4d6fd0a7..1ca3f835c 100644 --- a/Examples/test-suite/python/template_typemaps_typedef_runme.py +++ b/Examples/test-suite/python/template_typemaps_typedef_runme.py @@ -13,8 +13,8 @@ m2 = MultimapAInt() #dummy_pair = m2.make_dummy_pair() #val = m2.typemap_test(dummy_pair) -#print val -#if val != 4321: +# print val +# if val != 4321: # raise RuntimeError, "typemaps not working" if typedef_test1(dummy_pair).val != 1234: @@ -34,4 +34,3 @@ if typedef_test5(dummy_pair).val != 1234: if typedef_test6(dummy_pair).val != 1234: raise RuntimeError, "typedef_test6 not working" - diff --git a/Examples/test-suite/python/threads_exception_runme.py b/Examples/test-suite/python/threads_exception_runme.py index 6fe6947ec..056bd849b 100644 --- a/Examples/test-suite/python/threads_exception_runme.py +++ b/Examples/test-suite/python/threads_exception_runme.py @@ -2,40 +2,39 @@ import threads_exception t = threads_exception.Test() try: - t.unknown() -except RuntimeError,e: - pass + t.unknown() +except RuntimeError, e: + pass try: - t.simple() -except RuntimeError,e: - if e.args[0] != 37: - raise RuntimeError + t.simple() +except RuntimeError, e: + if e.args[0] != 37: + raise RuntimeError try: - t.message() -except RuntimeError,e: - if e.args[0] != "I died.": - raise RuntimeError + t.message() +except RuntimeError, e: + if e.args[0] != "I died.": + raise RuntimeError # This is expected fail with -builtin option # Throwing builtin classes as exceptions not supported 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: - t.multi(i) - except RuntimeError,e: - pass - except threads_exception.Exc,e: - pass + 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: + t.multi(i) + except RuntimeError, e: + pass + except threads_exception.Exc, e: + pass diff --git a/Examples/test-suite/python/typedef_class_runme.py b/Examples/test-suite/python/typedef_class_runme.py index 71436b399..6d2f2a5c3 100644 --- a/Examples/test-suite/python/typedef_class_runme.py +++ b/Examples/test-suite/python/typedef_class_runme.py @@ -1,7 +1,7 @@ import typedef_class -a = typedef_class.RealA() -a.a = 3 - -b = typedef_class.B() -b.testA(a) +a = typedef_class.RealA() +a.a = 3 + +b = typedef_class.B() +b.testA(a) diff --git a/Examples/test-suite/python/typedef_scope_runme.py b/Examples/test-suite/python/typedef_scope_runme.py index 37bfc97b1..edd3e9f3a 100644 --- a/Examples/test-suite/python/typedef_scope_runme.py +++ b/Examples/test-suite/python/typedef_scope_runme.py @@ -1,12 +1,10 @@ import typedef_scope b = typedef_scope.Bar() -x = b.test1(42,"hello") +x = b.test1(42, "hello") if x != 42: print "Failed!!" -x = b.test2(42,"hello") +x = b.test2(42, "hello") if x != "hello": print "Failed!!" - - diff --git a/Examples/test-suite/python/typedef_typedef_runme.py b/Examples/test-suite/python/typedef_typedef_runme.py index 1d83065a6..92e85c27e 100644 --- a/Examples/test-suite/python/typedef_typedef_runme.py +++ b/Examples/test-suite/python/typedef_typedef_runme.py @@ -2,4 +2,4 @@ import typedef_typedef b = typedef_typedef.B() if b.getValue(123) != 1234: - raise Exception("Failed") + raise Exception("Failed") diff --git a/Examples/test-suite/python/typemap_arrays_runme.py b/Examples/test-suite/python/typemap_arrays_runme.py index c23222c63..ea0f08d6b 100644 --- a/Examples/test-suite/python/typemap_arrays_runme.py +++ b/Examples/test-suite/python/typemap_arrays_runme.py @@ -2,4 +2,3 @@ from typemap_arrays import * if sumA(None) != 60: raise RuntimeError, "Sum is wrong" - diff --git a/Examples/test-suite/python/typemap_namespace_runme.py b/Examples/test-suite/python/typemap_namespace_runme.py index 581a0f437..b55eb8ba5 100644 --- a/Examples/test-suite/python/typemap_namespace_runme.py +++ b/Examples/test-suite/python/typemap_namespace_runme.py @@ -5,4 +5,3 @@ if test1("hello") != "hello": if test2("hello") != "hello": raise RuntimeError - diff --git a/Examples/test-suite/python/typemap_out_optimal_runme.py b/Examples/test-suite/python/typemap_out_optimal_runme.py index 95556f6bd..c7a34308e 100644 --- a/Examples/test-suite/python/typemap_out_optimal_runme.py +++ b/Examples/test-suite/python/typemap_out_optimal_runme.py @@ -2,4 +2,3 @@ from typemap_out_optimal import * cvar.XX_debug = False x = XX_create() - diff --git a/Examples/test-suite/python/typemap_qualifier_strip_runme.py b/Examples/test-suite/python/typemap_qualifier_strip_runme.py index 5e466cf69..dff94f8b4 100644 --- a/Examples/test-suite/python/typemap_qualifier_strip_runme.py +++ b/Examples/test-suite/python/typemap_qualifier_strip_runme.py @@ -51,4 +51,3 @@ if typemap_qualifier_strip.testD3(val) != 111: if typemap_qualifier_strip.testD4(val) != 111: raise RuntimeError - diff --git a/Examples/test-suite/python/typename_runme.py b/Examples/test-suite/python/typename_runme.py index 10c7bff1b..aac936fde 100644 --- a/Examples/test-suite/python/typename_runme.py +++ b/Examples/test-suite/python/typename_runme.py @@ -4,9 +4,8 @@ f = typename.Foo() b = typename.Bar() x = typename.twoFoo(f) -if not isinstance(x,types.FloatType): - raise RuntimeError,"Wrong return type (FloatType) !" +if not isinstance(x, types.FloatType): + raise RuntimeError, "Wrong return type (FloatType) !" y = typename.twoBar(b) -if not isinstance(y,types.IntType): - raise RuntimeError,"Wrong return type (IntType)!" - +if not isinstance(y, types.IntType): + raise RuntimeError, "Wrong return type (IntType)!" diff --git a/Examples/test-suite/python/types_directive_runme.py b/Examples/test-suite/python/types_directive_runme.py index c28453e84..401e3ae1d 100644 --- a/Examples/test-suite/python/types_directive_runme.py +++ b/Examples/test-suite/python/types_directive_runme.py @@ -1,12 +1,13 @@ from types_directive import * d1 = Time1(2001, 2, 3, 60) -newDate = add(d1, 7) # check that a Time1 instance is accepted where Date is expected +# check that a Time1 instance is accepted where Date is expected +newDate = add(d1, 7) if newDate.day != 10: - raise RuntimeError + raise RuntimeError d2 = Time2(1999, 8, 7, 60) -newDate = add(d2, 7) # check that a Time2 instance is accepted where Date is expected +# check that a Time2 instance is accepted where Date is expected +newDate = add(d2, 7) if newDate.day != 14: - raise RuntimeError - + raise RuntimeError diff --git a/Examples/test-suite/python/unions_runme.py b/Examples/test-suite/python/unions_runme.py index d59e2429e..387a048c8 100644 --- a/Examples/test-suite/python/unions_runme.py +++ b/Examples/test-suite/python/unions_runme.py @@ -1,5 +1,5 @@ -# This is the union runtime testcase. It ensures that values within a +# This is the union runtime testcase. It ensures that values within a # union embedded within a struct can be set and read correctly. import unions @@ -23,12 +23,12 @@ eut.number = 1 eut.uni.small = small Jill1 = eut.uni.small.jill if (Jill1 != 200): - print "Runtime test1 failed. eut.uni.small.jill=" , Jill1 + print "Runtime test1 failed. eut.uni.small.jill=", Jill1 sys.exit(1) Num1 = eut.number if (Num1 != 1): - print "Runtime test2 failed. eut.number=" , Num1 + print "Runtime test2 failed. eut.number=", Num1 sys.exit(1) # Secondly check the BigStruct in EmbeddedUnionTest @@ -36,16 +36,15 @@ eut.number = 2 eut.uni.big = big Jack1 = eut.uni.big.jack if (Jack1 != 300): - print "Runtime test3 failed. eut.uni.big.jack=" , Jack1 + print "Runtime test3 failed. eut.uni.big.jack=", Jack1 sys.exit(1) Jill2 = eut.uni.big.smallstruct.jill if (Jill2 != 200): - print "Runtime test4 failed. eut.uni.big.smallstruct.jill=" , Jill2 + print "Runtime test4 failed. eut.uni.big.smallstruct.jill=", Jill2 sys.exit(1) Num2 = eut.number if (Num2 != 2): - print "Runtime test5 failed. eut.number=" , Num2 + print "Runtime test5 failed. eut.number=", Num2 sys.exit(1) - diff --git a/Examples/test-suite/python/using_composition_runme.py b/Examples/test-suite/python/using_composition_runme.py index 6baa16d13..c4f339095 100644 --- a/Examples/test-suite/python/using_composition_runme.py +++ b/Examples/test-suite/python/using_composition_runme.py @@ -2,33 +2,32 @@ from using_composition import * f = FooBar() if f.blah(3) != 3: - raise RuntimeError,"FooBar::blah(int)" + raise RuntimeError, "FooBar::blah(int)" if f.blah(3.5) != 3.5: - raise RuntimeError,"FooBar::blah(double)" + raise RuntimeError, "FooBar::blah(double)" if f.blah("hello") != "hello": - raise RuntimeError,"FooBar::blah(char *)" + raise RuntimeError, "FooBar::blah(char *)" f = FooBar2() if f.blah(3) != 3: - raise RuntimeError,"FooBar2::blah(int)" + raise RuntimeError, "FooBar2::blah(int)" if f.blah(3.5) != 3.5: - raise RuntimeError,"FooBar2::blah(double)" + raise RuntimeError, "FooBar2::blah(double)" if f.blah("hello") != "hello": - raise RuntimeError,"FooBar2::blah(char *)" + raise RuntimeError, "FooBar2::blah(char *)" f = FooBar3() if f.blah(3) != 3: - raise RuntimeError,"FooBar3::blah(int)" + raise RuntimeError, "FooBar3::blah(int)" if f.blah(3.5) != 3.5: - raise RuntimeError,"FooBar3::blah(double)" + raise RuntimeError, "FooBar3::blah(double)" if f.blah("hello") != "hello": - raise RuntimeError,"FooBar3::blah(char *)" - + raise RuntimeError, "FooBar3::blah(char *)" diff --git a/Examples/test-suite/python/using_extend_runme.py b/Examples/test-suite/python/using_extend_runme.py index 14615a05e..038a1686a 100644 --- a/Examples/test-suite/python/using_extend_runme.py +++ b/Examples/test-suite/python/using_extend_runme.py @@ -2,20 +2,20 @@ from using_extend import * f = FooBar() if f.blah(3) != 3: - raise RuntimeError,"blah(int)" + raise RuntimeError, "blah(int)" if f.blah(3.5) != 3.5: - raise RuntimeError,"blah(double)" + raise RuntimeError, "blah(double)" if f.blah("hello") != "hello": - raise RuntimeError,"blah(char *)" + raise RuntimeError, "blah(char *)" -if f.blah(3,4) != 7: - raise RuntimeError,"blah(int,int)" +if f.blah(3, 4) != 7: + raise RuntimeError, "blah(int,int)" -if f.blah(3.5,7.5) != (3.5+7.5): - raise RuntimeError,"blah(double,double)" +if f.blah(3.5, 7.5) != (3.5 + 7.5): + raise RuntimeError, "blah(double,double)" if f.duh(3) != 3: - raise RuntimeError,"duh(int)" + raise RuntimeError, "duh(int)" diff --git a/Examples/test-suite/python/using_inherit_runme.py b/Examples/test-suite/python/using_inherit_runme.py index b00e66ec3..4fd595968 100644 --- a/Examples/test-suite/python/using_inherit_runme.py +++ b/Examples/test-suite/python/using_inherit_runme.py @@ -2,48 +2,47 @@ from using_inherit import * b = Bar() if b.test(3) != 3: - raise RuntimeError,"Bar::test(int)" + raise RuntimeError, "Bar::test(int)" if b.test(3.5) != 3.5: - raise RuntimeError, "Bar::test(double)" + raise RuntimeError, "Bar::test(double)" b = Bar2() if b.test(3) != 6: - raise RuntimeError,"Bar2::test(int)" + raise RuntimeError, "Bar2::test(int)" if b.test(3.5) != 7.0: - raise RuntimeError, "Bar2::test(double)" + raise RuntimeError, "Bar2::test(double)" b = Bar3() if b.test(3) != 6: - raise RuntimeError,"Bar3::test(int)" + raise RuntimeError, "Bar3::test(int)" if b.test(3.5) != 7.0: - raise RuntimeError, "Bar3::test(double)" + raise RuntimeError, "Bar3::test(double)" b = Bar4() if b.test(3) != 6: - raise RuntimeError,"Bar4::test(int)" + raise RuntimeError, "Bar4::test(int)" if b.test(3.5) != 7.0: - raise RuntimeError, "Bar4::test(double)" + raise RuntimeError, "Bar4::test(double)" b = Fred1() if b.test(3) != 3: - raise RuntimeError,"Fred1::test(int)" + raise RuntimeError, "Fred1::test(int)" if b.test(3.5) != 7.0: - raise RuntimeError, "Fred1::test(double)" + raise RuntimeError, "Fred1::test(double)" b = Fred2() if b.test(3) != 3: - raise RuntimeError,"Fred2::test(int)" + raise RuntimeError, "Fred2::test(int)" if b.test(3.5) != 7.0: - raise RuntimeError, "Fred2::test(double)" - + raise RuntimeError, "Fred2::test(double)" diff --git a/Examples/test-suite/python/varargs_overload_runme.py b/Examples/test-suite/python/varargs_overload_runme.py index a3b2068b5..37958620c 100644 --- a/Examples/test-suite/python/varargs_overload_runme.py +++ b/Examples/test-suite/python/varargs_overload_runme.py @@ -28,4 +28,3 @@ if varargs_overload.vararg_over4(123) != "123": if varargs_overload.vararg_over4("Hello", 123) != "Hello": raise RuntimeError, "Failed" - diff --git a/Examples/test-suite/python/varargs_runme.py b/Examples/test-suite/python/varargs_runme.py index 2c68f4e06..7105ba8d7 100644 --- a/Examples/test-suite/python/varargs_runme.py +++ b/Examples/test-suite/python/varargs_runme.py @@ -11,7 +11,7 @@ if f.test("Hello") != "Hello": raise RuntimeError, "Failed" -if varargs.test_def("Hello",1) != "Hello": +if varargs.test_def("Hello", 1) != "Hello": raise RuntimeError, "Failed" if varargs.test_def("Hello") != "Hello": diff --git a/Examples/test-suite/python/virtual_derivation_runme.py b/Examples/test-suite/python/virtual_derivation_runme.py index 8a6e743af..68546c6eb 100644 --- a/Examples/test-suite/python/virtual_derivation_runme.py +++ b/Examples/test-suite/python/virtual_derivation_runme.py @@ -4,5 +4,4 @@ from virtual_derivation import * # b = B(3) if b.get_a() != b.get_b(): - raise RuntimeError, "something is really wrong" - + raise RuntimeError, "something is really wrong" diff --git a/Examples/test-suite/python/virtual_poly_runme.py b/Examples/test-suite/python/virtual_poly_runme.py index 7e202f9cf..0df6271ef 100644 --- a/Examples/test-suite/python/virtual_poly_runme.py +++ b/Examples/test-suite/python/virtual_poly_runme.py @@ -5,25 +5,25 @@ i = virtual_poly.NInt(2) # # the copy methods return the right polymorphic types -# +# dc = d.copy() ic = i.copy() if d.get() != dc.get(): - raise RuntimeError + raise RuntimeError if i.get() != ic.get(): - raise RuntimeError + raise RuntimeError virtual_poly.incr(ic) if (i.get() + 1) != ic.get(): - raise RuntimeError + raise RuntimeError dr = d.ref_this() if d.get() != dr.get(): - raise RuntimeError + raise RuntimeError # @@ -31,8 +31,8 @@ if d.get() != dr.get(): # ddc = virtual_poly.NDouble_narrow(d.nnumber()) if d.get() != ddc.get(): - raise RuntimeError + raise RuntimeError dic = virtual_poly.NInt_narrow(i.nnumber()) if i.get() != dic.get(): - raise RuntimeError + raise RuntimeError diff --git a/Examples/test-suite/python/voidtest_runme.py b/Examples/test-suite/python/voidtest_runme.py index a7b421d6e..b16cacf00 100644 --- a/Examples/test-suite/python/voidtest_runme.py +++ b/Examples/test-suite/python/voidtest_runme.py @@ -6,10 +6,11 @@ f.memberfunc() voidtest.Foo_staticmemberfunc() + def fvoid(): pass -if f.memberfunc() != fvoid(): +if f.memberfunc() != fvoid(): raise RuntimeError diff --git a/Examples/test-suite/python/wrapmacro_runme.py b/Examples/test-suite/python/wrapmacro_runme.py index 0272afd5d..5e28d6bc9 100644 --- a/Examples/test-suite/python/wrapmacro_runme.py +++ b/Examples/test-suite/python/wrapmacro_runme.py @@ -2,6 +2,6 @@ import wrapmacro a = 2 b = -1 -wrapmacro.maximum(a,b) -wrapmacro.maximum(a/7.0, -b*256) +wrapmacro.maximum(a, b) +wrapmacro.maximum(a / 7.0, -b * 256) wrapmacro.GUINT16_SWAP_LE_BE_CONSTANT(1)