<p>Does Python have a unit testing framework compatible with the standard xUnit style of test framework? If so, what is it, where is it, and is it any good?</p>

[{'answer_id': 36648, 'author': 'John Millikin', 'author_id': 3560, 'author_profile': 'https://Stackoverflow.com/users/3560', 'pm_score': 6, 'selected': True, 'text': '<p>Python has several testing frameworks, including <code>unittest</code>, <code>doctest</code>, and <code>nose</code>. The most xUnit-like is <code>unittest</code>, which is documented on Python.org.</p>\n\n<ul>\n<li><a href="https://docs.python.org/3/library/unittest.html" rel="nofollow noreferrer"><code>unittest</code> documentation</a></li>\n<li><a href="https://docs.python.org/3/library/doctest.html" rel="nofollow noreferrer"><code>doctest</code> documentation</a></li>\n</ul>\n'}, {'answer_id': 36651, 'author': 'Yon', 'author_id': 3117, 'author_profile': 'https://Stackoverflow.com/users/3117', 'pm_score': 2, 'selected': False, 'text': '<p>There\'s <a href="http://testoob.sourceforge.net/" rel="nofollow noreferrer">testoob</a> which is pretty complete suite of test.Also xUnit-ie, and has a nice reporting option</p>\n'}, {'answer_id': 36653, 'author': 'Greg Hewgill', 'author_id': 893, 'author_profile': 'https://Stackoverflow.com/users/893', 'pm_score': 0, 'selected': False, 'text': '<p>There is also <a href="http://pyunit.sourceforge.net/" rel="nofollow noreferrer">PyUnit</a> which might be what you\'re looking for.</p>\n'}, {'answer_id': 36654, 'author': 'John Millikin', 'author_id': 3560, 'author_profile': 'https://Stackoverflow.com/users/3560', 'pm_score': 2, 'selected': False, 'text': '<p>@Greg: PyUnit is included in the standard library as <code>unittest</code></p>\n'}, {'answer_id': 36800, 'author': 'Blair Conrad', 'author_id': 1199, 'author_profile': 'https://Stackoverflow.com/users/1199', 'pm_score': 2, 'selected': False, 'text': '<p>Consider <a href="http://codespeak.net/py/dist/test.html" rel="nofollow noreferrer">py.test</a>. Not exactly analogous to NUnit, but very good, with nice features including test auto-discovery and a "Watch the tests and code - when something changes rerun the tests that failed last time. As soon as all the tests pass, switch to running all the tests whenever somethings changes." option.</p>\n'}, {'answer_id': 36835, 'author': 'dbr', 'author_id': 745, 'author_profile': 'https://Stackoverflow.com/users/745', 'pm_score': 0, 'selected': False, 'text': '<p>Never used xUnit, so I can\'t tell you if the frameworks are good/bad comparativly, but <a href="http://github.com/dbr/tvdb_api/tree/master/tvdb_api.py#L518-575" rel="nofollow noreferrer">here</a> is a script I wrote which uses the unittest framework (to check the API works as it should), and the doctest (to check the examples I\'ve given work)</p>\n\n<p>My only problem is checking something raises an exception is slightly convoluted (you have to pass it a function/lambda that raises the exception, rather than just the command itself, like the rest of the framework).. Other than that, it does what it should, reliably, and it has been included in the default python distribution for quite some time.</p>\n'}, {'answer_id': 37620, 'author': 'codeape', 'author_id': 3571, 'author_profile': 'https://Stackoverflow.com/users/3571', 'pm_score': 3, 'selected': False, 'text': '<p>I recommend <a href="https://nose.readthedocs.org/en/latest/" rel="nofollow noreferrer">nose</a>.</p>\n\n<p>It is the most Pythonic of the unit test frameworks. The test runner runs both doctests and unittests, so you are free to use whatever style of test you like.</p>\n'}, {'answer_id': 1310119, 'author': 'Chris', 'author_id': 160507, 'author_profile': 'https://Stackoverflow.com/users/160507', 'pm_score': 1, 'selected': False, 'text': '<p>I recommend Nose. </p>\n\n<p>After the reasonable simple installation, you just have to run "nosetests" in your project folder and Nose will find all your tests and run them. I also like the collection of plugins (coverage, GAE, etc.) and the abilty to call Nose directly from within my Python scripts. </p>\n'}, {'answer_id': 2194729, 'author': 'Binary Phile', 'author_id': 75182, 'author_profile': 'https://Stackoverflow.com/users/75182', 'pm_score': 0, 'selected': False, 'text': "<p>nose seems to be the best combination of flexibility and convenience.  It runs unittests, doctests, coverage (with an extension) and py.test-like tests from one framework and does so admirably.  It has enough popularity that it has had some IDE integration done as well for Komodo Edit and I wouldn't be surprised to see it elsewhere as well.</p>\n\n<p>I like it for one strong reason: I almost always doctest before writing more extensive tests in another framework.  This is because, for basic tests, doctests kill two birds with one stone.  You get executable tests (although they are a bit clumsy to write well sometimes) as well as API documentation and interactive documentation at the same time.  nose will run these with the bundled doctest extension when you use a command-line option (--with-doctest).</p>\n\n<p>I say this having come from py.test as my former favorite.  While it is great, nose tests are similar enough to me that I don't miss it, and I like the integration of the various test methodologies under one roof, so to speak.  YMMV, but I recommend taking a good look at nose before choosing another.  If you aren't familiar with py.test tests, you should look at them as well.  I find them terrific because they are usually written in such a way that they can be easily debugged <em>without</em> the testing framework, which makes one less tricky system involved in the debugging session.  I find that alone invaluable, while they are also easier to write than unittest tests in my opinion.</p>\n"}]
['https://Stackoverflow.com/questions/36647', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/577/']