On Apr 23, 2015, at 08:05 AM, Nikolaus Rath wrote:

>Are you by any chance also familiar with pytest and could same a few
>word about pros/cons?

Of course this is all personal opinion, so take with a grain of salt.  I know
a lot of people really like pytest but I don't use it.  I don't like the use
of assert, and I think the output is a bit too verbose for my tastes.

I use stdlib unittest with its plethora of .assert*() methods.  Some folks
think there's too many of those and they're hard to remember.  Usually I find
it easy enough to remember the 80% I use all the time, and then I just look up
some of the more obscure ones (e.g. assertMultiLineEqual() when I can't
remember if the 'L' is capitalized or not ;).

What I like about nose2 is its plugin and event architecture for
extensibility, which I think is a big improvement over nose (it's not
maintenance-only precursor).  There nose2 plugins for doing zope.testrunner
style layers, which is a resource management technique.  There are definitely
other options for that (fixtures, etc).  I usually carry around a my own
plugins to do zope.testrunner style test narrowing, system-wide startups, and
per-test diagnostics.

E.g. I can do something like:

    .tox/py34/bin/python -m nose2 -vv -P test_some_specific_thing

The thing after the -P (of which multiple can be given) can be any Python
regex, and it can match a test method, test class, test module, package path,
doctest, or any combination.  It really helps me quickly narrow down to any
regressions or other failures without wasting time running the full test
suite every time.

I can also do setups and teardowns (e.g. of a D-Bus service) for the entire
test suite, and I can interpose at many levels for doing additional work
(e.g. logging) when individual tests start and stop.

nose2's plugin/event architecture makes all this really really easy to write.

TL;DR: I use stdlib unittest for writing tests, and nose2 as my test runner.

>I've chosen pytest over nose1 because of the richer feature set for
>writing tests, but I think in several cases pytest is suffering from its
>own complexity (eg. https://bitbucket.org/pytest-dev/pytest/issue/635/).
>Reading your comment I was wondering if nose2 might be a better choice,
>but the nose2 manual wasn't very informative at all (I actually did not
>found any information about how to write tests).

Right, because you already know how... unittest! :)

Nothing against pytest, it just doesn't fit my brain.

Cheers,
-Barry

Attachment: pgpy1EEGsqJig.pgp
Description: OpenPGP digital signature

Reply via email to