[TIP] pytest and nose - what's to choose between them?

Barry Warsaw barry at python.org
Fri Aug 30 11:22:44 PDT 2013

On Aug 30, 2013, at 06:39 PM, Chris Withers wrote:

>On 13/08/2013 19:07, Barry Warsaw wrote:
>> For example, I can't really use the doctest plugin because of
>> https://github.com/nose-devs/nose/issues/594
>Just use Manuel and be done with it :-)

I looked at Manuel when it was first announced.  No doubt it's come a long way
since then.  I don't remember why I ended up not pursing that.  I should
really look at it again.

>> On the positive side, I've had to change almost nothing about the structure
>> of my existing tests to migrate to nose.  My existing fixtures mostly work,
>> although I did have to do some reorganization to work around the
>> assumptions imposed by zc.testing's layer arrangement.  Instead of using
>> layers, I now use a base class.
>The layers problems is a complex one, Robert Collins' testresources package
>is another take on this.

Actually, Jason's hint about nose2 was really perfect.  I ended up abandoning
the switch to nose for nose2, and it was really very easy.  I even got to keep
my layers virtually untouched.

>> One thing I really like about nose is the ability to write a plugin that
>> executes some code before the tests begin.  I had an ugly hack to do this
>> in zc.testing/zc.buildout but now I just add a begin() method to my plugin
>> and it does all the pre-initialization I need.
>Yep, love the plugin framework :-)
>That said, as a point of principle, I try and write tests that can be run
>with any runner: nose, zc.testing, unittest2. I think some of the features of
>pytest prevent that being possible which has kept me from looking at it...

For the most part, switching from zope.testing to nose2 required almost no
changes to existing code.  It was mostly in things like the pre-test
initialization and locating "special" tests that discovery normally doesn't
find (e.g. my doctests).  I wrote a tiny plugin that adds doctest support the
way I wanted it, including with layers and fixtures, and extended test filters
by providing something very similar to zope.testing's -t option.  With Jason's
help, the migration to nose2 was very satisfying, and I kept all the important
features I needed.

nose2 will soon be available in Debian and Ubuntu. :)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20130830/1375bcb3/attachment.pgp>

More information about the testing-in-python mailing list