What is the best unit testing framework for Python?
-
Some candidates, although not fully inclusive: unittest: http://docs.python.org/library/unittest.html unittest2: http://pypi.python.org/pypi/unittest2 Nose: http://readthedocs.org/docs/nose/en/latest/ mox: http://code.google.com/p/pymox/ pyunit: http://pyunit.sourceforge.net/ py.test: http://pytest.org/latest/ Although I'm sure there are others.
-
Answer:
nose: http://readthedocs.org/docs/nose/ "nose extends unittest to make testing easier." Nose is fairly widely used and has an active community. The plugins can be a bit arcane, but are very powerful. I would recommend pairing nose with fabric to create simple test runners that you can invoke with something like "fab test". from fabric.api import * import nose @task def test(*args): # perform custom initializations, for example pylons <...> # now run tests nose.main(argv=(["fabtest", "--with-doctest"] + list(args)))
Alex Khomenko at Quora Visit the source
Other answers
There's also nose2 which aims to be a replacement of nose and is written by their authors. For the most part though, I tend to avoid adding dependencies to my projects. Any project I've seen that uses nose usually uses it to run the tests while using unittest/unittest2 for everything else. I've never seen mox but it sounds a bit like mock. But that's for very specific test cases.
Ian Cordasco
Related Q & A:
- How to mock NSURLConnection.sendAsynchronousRequest in unit testing?Best solution by stackoverflow.com
- What is the best HD Radio Head Unit?Best solution by Yahoo! Answers
- What is the best way to learn how to build websites and web applications with Python?Best solution by Quora
- What Amp and head unit paired with this sub?Best solution by Yahoo! Answers
- Which is the best software testing institute in Bangalore?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.