summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2020-08-13 22:00:01 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2020-08-13 22:00:01 +0100
commitd82004533606327b340af483d7d5838539f65b83 (patch)
treec45f318873a9f0926fc39e13d7876190d8a38e9c
parent916955562870476171777b177562e6edc8c283d3 (diff)
downloadswig-d82004533606327b340af483d7d5838539f65b83.tar.gz
Improve director_exception Python test
Add code to handle missed exceptons. Remove print statement.
-rw-r--r--Examples/test-suite/python/director_exception_runme.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py
index 5b715bae6..77abd25a9 100644
--- a/Examples/test-suite/python/director_exception_runme.py
+++ b/Examples/test-suite/python/director_exception_runme.py
@@ -28,7 +28,7 @@ class MyFoo3(Foo):
class MyFoo4(Foo):
def ping(self, *args):
- print(type("bad", "call")) # throws TypeError message: type() takes 1 or 3 arguments
+ t = type("bad", "call") # throws TypeError message: type() takes 1 or 3 arguments
return "Foo4.ping"
@@ -38,6 +38,7 @@ a = MyFoo()
b = launder(a)
try:
b.pong()
+ raise RuntimeError("Exception was not thrown")
except NotImplementedError, e:
if not str(e) == "MyFoo::ping() EXCEPTION":
raise RuntimeError("Unexpected error message: %s" % str(e))
@@ -51,6 +52,7 @@ a = MyFoo2()
b = launder(a)
try:
b.pong()
+ raise RuntimeError("Exception was not thrown")
except TypeError, e:
# fastdispatch mode adds on Additional Information to the exception message - just check the main exception message exists
if not str(e).startswith("SWIG director type mismatch in output value of type 'std::string'"):
@@ -63,6 +65,7 @@ a = MyFoo3()
b = launder(a)
try:
b.pong()
+ raise RuntimeError("Exception was not thrown")
except MyException, e:
if e.msg != "foobar":
raise RuntimeError("Unexpected error message: %s" % str(e))
@@ -73,6 +76,7 @@ a = MyFoo4()
b = launder(a)
try:
b.pong()
+ raise RuntimeError("Exception was not thrown")
except TypeError as e:
if not str(e).startswith("type() takes 1 or 3 arguments"):
raise RuntimeError("Unexpected error message: %s" % str(e))