I have many situations when I use a SWIG-generated shell for unit testing the library, but I assume that you request this unit testing the shell itself.
As I tested the shell, let's say mylib:
Properties . For each class, say MyClasswith properties open, I use MyClass._swig_getmethods__to list all properties that can be changed. I verify that the correct number of properties are available and they work as expected
# Filter out builtin_function_type
getmethods = {k: v for k,v in mylib.MyClass.__swig_getmethods__.iteritems() if type(v) != types.BuiltinFunctionType}
# Filter out lambda functions (constructors)
getmethods = {k: v for k,v in getmethods.iteritems() if v.func_name != '<lambda>'}.keys()
nGetSuccess = 0
testMe = set()
m = mylib.MyClass()
for method in getmethods:
try:
value = eval('m.'+method)
nGetSuccess = nGetSuccess + 1
except Exception as e:
print(e.message)
self.assertEqual(nGetSuccess,len(getmethods))
Static methods
mylib.__dict__ . , , C struct Python , .