unittest vs py.test?

Peter Hansen peter at engcorp.com
Sat Apr 2 10:26:21 EST 2005


Raymond Hettinger wrote:
> [Peter Hansen]
> 
>>This is pretty, but I *want* my tests to be contained
>>in separate functions or methods.
> 
> 
> In py.test, those would read:
> 
> def test1():
>     assert a == b
> 
> def test2():
>     raises(Error, func, args)
> 
> Enclosing classes are optional.

So basically py.test skips the import statement,
near as I can tell, at the cost of requiring a
utility to be installed in the PATH.

Where was all that weight that unittest supposedly
has?

(I'm not dissing py.test, and intend to check it
out.  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...)

-Peter



More information about the Python-list mailing list