Fri 1 Sep 2006
Following up on an earlier post, I’ve just submitted a trio of patches for Python’s unittest module to SourceForge:
-
Patch #1550272 is the test suite itself. It comprises 128 tests for the mission-critical parts of unittest.
-
Patch #1550273 fixes 6 issues uncovered while writing the test suite. Several other items that I raised earlier were judged to be either non-issues or behaviours that, while suboptimal, people have come to rely on.
-
Patch #1550263 follows up on an earlier patch I submitted for unittest’s docs. This new patch corrects and clarifies numerous sections of the module’s documentation.
I’m hopeful that these changes will make it into Python 2.5-final or 2.5.1 at the latest.
Here’s a list of the issues I uncovered while writing the test suite:
-
TestLoader.loadTestsFromName()failed to return a suite when resolving a name to a callable that returns aTestCaseinstance. -
Fix a bug in both
TestSuite.addTest()andTestSuite.addTests()concerning a lack of input checking on the input test case(s)/suite(s). -
Fix a bug in both
TestLoader.loadTestsFromName()andTestLoader.loadTestsFromNames()that hadValueErrorbeing raised instead ofTypeError. The problem occured when the given name resolved to a callable and the callable returned something of the wrong type. -
When a name resolves to a method on a
TestCase
subclass,TestLoader.loadTestsFromName()did not return
a suite as promised. -
TestLoader.loadTestsFromName()would raise aValueError (rather than aTypeError) if a name resolved to an invalid object. This has been fixed so that aTypeErroris raised. -
TestResult.shouldStopwas being initialised to 0 inTestResult.__init__. Since this attribute is always used in a boolean context, it’s better to use theFalse
spelling.