unittest vs py.test?

Raymond Hettinger vze4rx4y at verizon.net
Sun Apr 3 07:24:50 EDT 2005


[Peter Hansen]
> (I'm not dissing py.test, and intend to check it
> out.

Not to be disrepectful, but objections raised by someone
who hasn't worked with both tools equate to hot air.


> I'm just objecting to claims that unittest
> somehow is "heavy", when those claiming that it
> is seem to think you have to use TestSuites and
> TestRunner objects directly... I think they've
> overlooked the relatively lightweight approach
> that has worked so well for me for four years...)

Claiming?  Overlooked?  You do know that I wrote the
example in unittest docs, the tutorial example, and hundreds
of the test cases in the standard library. It is not an
uninformed opinion that the exposed object model for
unittest is more complex.

As for "heaviness", it is similar to comparing alkaline AA
batteries to lithium AA batteries.  The first isn't especially heavy,
but it does weigh twice as much as the latter.  It only becomes a
big deal when you have to carry a dozen battery packs on a hiking
trip.  My guess is that until you've written a full test suite with
py.test, you won't get it.  There is a distinct weight difference between
the packages -- that was their whole point in writing a new testing tool
when we already had two.

When writing a large suite, you quick come to appreciate being able
to use assert statements with regular comparision operators, debugging
with normal print statements, and not writing self.assertEqual over and
over again.  The generative tests are especially nice.

Until you've exercised both packages, you haven't helped the OP
whose original request was:  "Is there anybody out there who has
used both packages and can give a comparative review?"


Raymond





More information about the Python-list mailing list