[Pyunit-interest] Patch: more extensible PyUnit base classes
Brought to you by:
purcell
From: Pieter N. <pn...@tb...> - 2000-07-15 12:08:55
|
I extended TextTestRunner into a test harness suitable for use under Aegis[1], and in the process I needed to make the base classes more extensible. One problem is gratuitous underscore-privitization of names, i.e. I would really like to get at TestSuite's _test member in subclasses. I also think the object factory aproach of TestCase.defaultTestResult() should be extended to the TestRunner class, so that subclasses can decide to use appropriate TestResult subclasses. Here is a patch towards that. It also adds one fun change: if the test methods have doc strings, they also appear in the Test's string representation. That way one can do things like: class FrobTest(TestCase): def checkSnazzle(self): """Does the Frob tweak its snazzle after reset?""" self.frob.reset() assert self.frob.snazzle and have that textual comment of what is wrong when the test fails appear as part of the result. [1] Aegis http://www.canb.auug.org.au/~millerp/aegis/ is a great GPL revision control/CASE/process management tool which enforces unit testing before any changes are committed to the baseline. Aegis, Python and PyUnit will compliment each other very nicely as soon as some problems are sorted out in the next Aegis release. The test-infected community of this list might want to take a look at it. Steve will be pleased to hear that I submitted an Aegis/Python howto to the author which recommends PyUnit. -- ,_ /_) /| / / i e t e r / |/ a g e l |