[python] Replace uses of assert in testsuite

We're not supposed to assert for this, as mentioned in #1488.
This commit is contained in:
Olly Betts 2022-01-30 13:37:19 +13:00
commit 25f996a5c8
3 changed files with 37 additions and 25 deletions

View file

@ -1,11 +1,15 @@
import cpp11_template_explicit
def swig_assert_isinstance(a, b):
if not isinstance(a, b):
raise RuntimeError(str(a) + " not an instance of " + str(b))
# Call variants of the same templated function
t1 = cpp11_template_explicit.my_templated_function_int (1,1.0)
t2 = cpp11_template_explicit.my_templated_function_A (2,2.0)
t3 = cpp11_template_explicit.my_templated_function_TemperInt(3,3.0)
# Check return types
assert isinstance(t1,int)
assert isinstance(t2,cpp11_template_explicit.A)
assert isinstance(t3,cpp11_template_explicit.TemperInt)
swig_assert_isinstance(t1,int)
swig_assert_isinstance(t2,cpp11_template_explicit.A)
swig_assert_isinstance(t3,cpp11_template_explicit.TemperInt)