unittest: Proposal to add failUnlessNear

Tim Peters tim.peters at gmail.com
Tue Jul 20 04:31:50 CEST 2004


[John Roth]
> I think this is overkill. I find myself using a raw assert much of the time
> rather than unittest's specific test methods; it works just as well and I
> don't have to remember the blasted syntax!

It doesn't work as well, because assert stmts "vanish" when running
tests with -O.  Luckily,

    self.assert_(expression)

works fine in a unittest, with or without -O.

    self.assertEqual(e1, e2)

is usually a lot better than

    self.assert_(e1 == e2)

too, because the former displays the unequal values when it fails.



More information about the Python-list mailing list