On Tue, Jul 14, 2009 at 9:45 AM, A.T.Hofkamp<a.t.hofk...@tue.nl> wrote:
> Todd Matsumoto wrote:
>>
>> Hi,
>>
>> Does anyone know how to do a unittest assert for a type?

> For new-style classes, you should be able to do
>
>
> type(result) is Decimal

When possible, it's better to use assertEqual() rather than a plain
assert_() because you will get a better error message on failure.

If you write
  self.assert_(type(result) is Decimal)
on failure you will get an uninformative message like "assertion failed"

If you write
  self.assertEqual(type(result), Decimal)
you will get an error more like "float != Decimal"

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

Reply via email to