Issue 1078905: Docs for unittest run() methods are misleading (original) (raw)
In the unittest module, the methods TestCase.run() and TestSuite.run() are not very useful and the documentation for them is misleading. I'm not sure whether to call this a problem with the docs or the code, but I think the easiest fix is to change the docs.
From the documentation, you would think that to specialize the way a TestCase or TestSuite is run, you should override the run() methods. For example, you might try this:
The output from this program is just
My test
The problem is that the run() methods are never used by the rest of the framework. In both cases, run() is equivalent to call(), and it is call() that is actually used by the rest of the framework. To get the expected output, change 'run' to 'call' in four places, then you will see this:
Suite start MyTests run My test Suite end
I suggest that, at a minimum, the documentation should be changed to refer to call() instead of run for these two classes. Possibly the code should be changed to either get rid of run() or actually use it, but I'm not so sure this can be done without breaking existing usage.