[Tutor] unittests, testing a type

A.T.Hofkamp a.t.hofkamp at tue.nl
Tue Jul 14 15:45:18 CEST 2009


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


More information about the Tutor mailing list