diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2016-06-19 20:11:51 +0100 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2016-06-19 20:11:51 +0100 |
commit | cc7319f52f76a6591bab6c7f2306c526c869a9a7 (patch) | |
tree | 9e50dc2c267750a4bd022965349c13a6e9bde2a5 | |
parent | 84b06fa21b61c96eb7da49d73edb66e17de10821 (diff) | |
download | swig-cc7319f52f76a6591bab6c7f2306c526c869a9a7.tar.gz |
Replace assert from Python testcases with code that always runs.
assert code is sometimes not executed, eg when running python -O.
5 files changed, 18 insertions, 9 deletions
diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py index b742de285..1c7705f3e 100644 --- a/Examples/test-suite/python/cpp_static_runme.py +++ b/Examples/test-suite/python/cpp_static_runme.py @@ -14,4 +14,5 @@ else: StaticFunctionTest().static_func_2(1) StaticFunctionTest().static_func_3(1, 2) StaticMemberTest.static_int = 10 -assert StaticMemberTest.static_int == 10 +if not StaticMemberTest.static_int == 10: + raise RuntimeError("static_int not 10") diff --git a/Examples/test-suite/python/exception_classname_runme.py b/Examples/test-suite/python/exception_classname_runme.py index c78f4e68b..9a82c9105 100644 --- a/Examples/test-suite/python/exception_classname_runme.py +++ b/Examples/test-suite/python/exception_classname_runme.py @@ -1,4 +1,5 @@ import exception_classname a = exception_classname.Exception() -assert a.testfunc() == 42 +if a.testfunc() != 42: + raise RuntimeError("Not 42!") diff --git a/Examples/test-suite/python/operbool_runme.py b/Examples/test-suite/python/operbool_runme.py index 708dea786..cdef85abc 100644 --- a/Examples/test-suite/python/operbool_runme.py +++ b/Examples/test-suite/python/operbool_runme.py @@ -1,3 +1,4 @@ #!/usr/bin/env python import operbool -assert not operbool.Test() +if operbool.Test(): + raise RuntimeError("operbool failed") diff --git a/Examples/test-suite/python/python_destructor_exception_runme.py b/Examples/test-suite/python/python_destructor_exception_runme.py index 671eff3cc..ee71ab33b 100644 --- a/Examples/test-suite/python/python_destructor_exception_runme.py +++ b/Examples/test-suite/python/python_destructor_exception_runme.py @@ -26,8 +26,10 @@ def test1(): sys.stderr.flush() sys.stderr = stderr_saved - assert attributeErrorOccurred - assert buffer.getvalue().count("I am the ClassWithThrowingDestructor dtor doing bad things") >= 1 + if not attributeErrorOccurred: + raise RuntimeError("attributeErrorOccurred failed") + if not buffer.getvalue().count("I am the ClassWithThrowingDestructor dtor doing bad things") >= 1: + raise RuntimeError("ClassWithThrowingDestructor dtor doing bad things failed") class VectorHolder(object): def __init__(self, v): diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py index 3ce98bcdb..fa9c51437 100644 --- a/Examples/test-suite/python/unicode_strings_runme.py +++ b/Examples/test-suite/python/unicode_strings_runme.py @@ -13,11 +13,15 @@ if sys.version_info[0:2] >= (3, 1): if unicode_strings.non_utf8_std_string() != test_string: raise ValueError('Test comparison mismatch') +def check(s1, s2): + if s1 != s2: + raise RuntimeError("{} != {}".format(s1, s2)) + # Testing SWIG_PYTHON_2_UNICODE flag which allows unicode strings to be passed to C if sys.version_info[0:2] < (3, 0): - assert unicode_strings.charstring("hello1") == "hello1" - assert unicode_strings.charstring(str(u"hello2")) == "hello2" - assert unicode_strings.charstring(u"hello3") == "hello3" - assert unicode_strings.charstring(unicode("hello4")) == "hello4" + check(unicode_strings.charstring("hello1"), "hello1") + check(unicode_strings.charstring(str(u"hello2")), "hello2") + check(unicode_strings.charstring(u"hello3"), "hello3") + check(unicode_strings.charstring(unicode("hello4")), "hello4") unicode_strings.charstring(u"hell\xb05") unicode_strings.charstring(u"hell\u00f66") |