Todd Matsumoto wrote:
Hi,

Does anyone know how to do a unittest assert for a type?
So If you have a program returning a Decimal, lets say Decimal("1"), and you 
want to make sure that what is returned is a Decimal object.

At first I thought of importing Decimal and making my own Decimal("1") and
doing an assertEquals, but this implies I know what the return type is before
getting it.


For new-style classes, you should be able to do


type(result) is Decimal



(since the class is a singleton, 'is' should work).


Albert
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to