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

Kenny theotherwhitemeat at gmail.com
Tue Aug 13 15:12:12 PDT 2013

Hey folks,

  I spent some time evaluating testing tools for Python with a focus on
py.test and nose.  My notes below are cursory, and may be informative for
your purposes:


                parallelizable: threading + SMP support [3][4]

                better documentation: [1][3]

                can generate script that does all py.test functions,
obviating the need to distribute py.test [1][10]

                                integrate tests into your distribution
(py.test --genscript=runtests.py), to create a standalone version of
py.test [10]

                can run nose, unittest, doctest style tests [1][2]

                test detection via globs, configurable [3]

                test failure output more discernible than nose [3][9]

                easier, more flexible assertions than nose [8]

                setup speed is sub-second different from nose, also test
speeds can be managed via distribution (threads + SMP via xdist) [9][11]

                provides test isolation, if needed [9]

                dependency injection via funcargs [10][12][13]

                coverage plugin [11]


                documentation concerns, this may be outdated [3]

                parallelization issues [3][8]

                slightly faster than py.test [4][11]

                test detection via regex (setup in cmdline or config file)

                can run unittest, doctest style tests [1][2]

                cannot run py.test style tests [1]


·         test formats are so similar, that nose or py.text can be used
without much consequence until you're writing more exotic tests (you could
swap with little consequence)

·         nose is sub-second faster than py.test in execution time; this is
typically unimportant

·         community seems to slightly favor py.test


[1] http://mail.scipy.org/pipermail/astropy/2011-July/001673.html

 [2] http://pytest.org/latest/nose.html

 [3] http://fedoraproject.org/wiki/User:Tflink/AutoQA_nose_pytest_comparison


 [5] http://pythontesting.net/framework/nose/nose-introduction/

 [6] http://wiki.python.org/moin/PythonTestingToolsTaxonomy

 [7] http://docs.python-guide.org/en/latest/writing/tests.html#tools


 [9] http://thread.gmane.org/gmane.comp.python.testing.general/3748

 [10] http://article.gmane.org/gmane.comp.python.testing.general/3752

 [11] http://article.gmane.org/gmane.comp.python.testing.general/3765

 [12] http://pytest.org/latest/funcargs.html


On Tue, Aug 13, 2013 at 6:28 AM, Emily Bache <emily.bache at cantab.net> wrote:

> Hi,
> I've been looking at pytest and nose as alternatives to unittest, since
> they both offer a pythonic interface for writing unit tests without too
> much boilerplate. I was hoping for some opinions from this list about when
> to choose nose and when to choose pytest? What are the main advantages of
> each? My target python version is 3.3, does that make a difference?
> Regards,
> Emily Bache
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20130813/9af6d2ea/attachment.htm>

More information about the testing-in-python mailing list