[TIP] unittest2 and the future of nose

Kumar McMillan kumar.mcmillan at gmail.com
Thu Mar 4 13:14:45 PST 2010

On Thu, Mar 4, 2010 at 2:51 PM, jason pellerin <jpellerin at gmail.com> wrote:
> Fact: unittest2 is coming:
> http://www.voidspace.org.uk/python/articles/unittest2.shtml
> ... indeed, it's already here (just not yet in stdlib). It does test
> discovery (though not by default), can support test functions (though
> not by default), will eventually support a better form of
> parameterized tests than nose does, and also will eventually support
> at least class and module-level fixtures.
> Which means it's not going to happen unless enough of you folks are
> interested and have time to commit.
> What do you think?

My gut reaction to all this is that unittest2 probably replaces most
of Nose's functionality besides plugin support.  I say gut reaction
because I would need to think about it harder and dig into unittest2
deeper to be sure.

That said, one HUGE win for unittest2 would be if it could support
Nose's plugin API.  In fact, most of the "features" in Nose are
implemented as plugins.  From Nose's source, here are the builtin
plugins (to give you an idea) :

    ('nose.plugins.attrib', 'AttributeSelector'),
    ('nose.plugins.capture', 'Capture'),
    ('nose.plugins.logcapture', 'LogCapture'),
    ('nose.plugins.cover', 'Coverage'),
    ('nose.plugins.debug', 'Pdb'),
    ('nose.plugins.doctests', 'Doctest'),
    ('nose.plugins.isolate', 'IsolationPlugin'),
    ('nose.plugins.failuredetail', 'FailureDetail'),
    ('nose.plugins.prof', 'Profile'),
    ('nose.plugins.skip', 'Skip'),
    ('nose.plugins.testid', 'TestId'),
    ('nose.plugins.multiprocess', 'MultiProcess'),
    ('nose.plugins.xunit', 'Xunit'),
    ('nose.plugins.collect', 'CollectOnly'),

These are all documented here:

So, if someone implements Nose's plugin interface in unittest2 you
might just get all those for free!  There are definitely some warts in
the plugin API though.  One area is output capturing and redirection,
another is error handling, there are probably others.  Otherwise the
API is pretty straightforward, you get a hook for most of anything you
ever need to do with test data:

The only part of Nose that is not implemented as a plugin that is not
scheduled to be supported by unittest2 (yet) is config file support (I
think?).  You can turn on any command line option in a config file
which is really crucial for projects that depend on a lot of plugins:


More information about the testing-in-python mailing list