[Tutor] unittests, testing a type

Todd Matsumoto tmatsumoto at gmx.net
Tue Jul 14 15:59:19 CEST 2009


Thanks that worked. 

I still needed to import the Decimal class and I'm not sure that is okay. The reason why is I'm receiving the Decimal value from another program, if I already know that the value will be a Decimal why test it?

Perhaps I'm getting to caught up in this test-driven development thing.



-------- Original-Nachricht --------
> Datum: Tue, 14 Jul 2009 15:45:18 +0200
> Von: "A.T.Hofkamp" <a.t.hofkamp at tue.nl>
> An: Todd Matsumoto <tmatsumoto at gmx.net>
> CC: "tutor at python.org" <tutor at python.org>
> Betreff: Re: [Tutor] unittests, testing a type

> 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

GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

More information about the Tutor mailing list