unittest: Proposal to add failUnlessNear

Tim Peters tim.peters at gmail.com
Mon Jul 19 22:31:50 EDT 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