unittest vs py.test?

Raymond Hettinger vze4rx4y at verizon.net
Fri Apr 1 01:04:53 EST 2005


[Roy Smith]
> I've used the standard unittest (pyunit) module on a few projects in the
> past and have always thought it basicly worked fine but was just a little
> too complicated for what it did.
>
> I'm starting a new project now and I'm thinking of trying py.test
> (http://codespeak.net/py/current/doc/test.html).  It looks pretty cool from
> the docs.  Is there anybody out there who has used both packages and can
> give a comparative review?

I've used both and found py.test to be effortless and much less verbose.
For more complex testing strategies, py.test is also a winner.  The generative
tests are easier to write than crafting a similar strategy for unittest.

py.test does not currently integrate well with doctest; however, that will
likely
be the next feature to be added (per holger's talk at PyCon).

For output, unittest's TextTestRunner produces good looking, succinct output
on successful tests.  For failed tests, it is not bad either.  In contrast,
py.test
output is more highly formatted and voluminous -- it takes a while to get used
to.

unittest users have to adapt to the internal structure of the unittest module
and
become familiar with its class structure (test fixture, test case, test suite,
and test
runner objects).  py.test does a good job of hiding its implementation.

py.test is relatively new and is continuing to evolve.  Support tools like a
GUI test runner are just emerging.  In contrast, unittest is based on a proven
model and the code is mature.

unittest module updates come up in distinct releases, often months or years
apart.  py.test is subject to constant update by subversion.  Personally, I like
the continuous updates, but it could be unsettling if you're depending on it
for production code.


Raymond Hettinger






More information about the Python-list mailing list