Ian Bicking: the old part of his blog


1. You don't need suites. Just add:

if __name__ == '__main__': unittest.main()

at the end of your file, and you can run the script and it'll find all the tests and automatically run them.

2. assertEquals is useful. The reason is, if it fails, you get to see what two values were, whereas "assert x == y" won't display the difference. Also you should be writing multiple test cases per class, not one, and using setUp and tearDown. Passing info for tests in __init__ shouldn't be done. Each test should set it up itself, or if its for all tests in the class, use setUp.

3. It is kinda limited. Twisted ended up writing an API compatible system that is more powerful in many ways (and customized to our needs), and has a command line test running tool, so you can say "trial twisted.test" and it runs all tests in the modules in that package. Zope3 has written a similar commandline tool for python's unittest.
Comment on Unittest Rant
by Itamar Shtull-Trauring