Colin J. Williams wrote:
unittest seems rather heavy. I don't like mixing tests with
documentation, it gives the whole thing a cluttered look.
unittest can really be rather light. Most of our
test cases are variations on the following, with
primarily application-specific code added rather than
boilerplate or other unittest-related stuff:
import unittest
class TestCase(unittest.TestCase):
def test01(self):
'''some test....'''
self.assertEquals(a, b)
def test02(self):
'''another test'''
self.assertRaises(Error, func, args)
if __name__ == '__main__':
unittest.main()
That's it... add testXX() methods as required and
they will be executed in sorted order (alphabetically)
automatically when you run from the command line.
The above might look excessive in comparison to the
test code, but add some real code and the overhead
quickly dwindles to negligible.
I'm a little puzzled why folks so often consider this
particularly "heavy". No need to deal with suites,
TestResult objects, etc, as others have suggested,
unless you are trying to extend it in some special
way.
-Peter
--
http://mail.python.org/mailman/listinfo/python-list