verify the return value of a function

Jabba Laci jabba.laci at gmail.com
Thu Jan 19 15:45:38 EST 2012


Hi,

In a unit test, I want to verify that a function returns a
cookielib.LWPCookieJar object. What is the correct way of doing that?

1) First I tried to figure out its type with type(return_value) but it
is <type 'instance'>

2) return_value.__class__ .__name__ gives 'LWPCookieJar', which is bettter

3) isinstance(return_value, cookielib.LWPCookieJar) seems to be the
best way, however somewhere I read that using isinstance is
discouraged

Thanks,

Laszlo



More information about the Python-list mailing list