[Python-Dev] A test suite for unittest

Collin Winter collinw at gmail.com
Fri Sep 1 04:52:02 CEST 2006

I've just uploaded a trio of unittest-related patches:

#1550272 (http://python.org/sf/1550272) is a test suite for the
mission-critical parts of unittest.

#1550273 (http://python.org/sf/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.

#1550263 (http://python.org/sf/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'd appreciate it if these changes could make it into 2.5-final or at
least 2.5.1.

What follows is a list of the issues fixed in patch #1550273:

1) TestLoader.loadTestsFromName() failed to return a
suite when resolving a name to a callable that returns
a TestCase instance.

2) Fix a bug in both TestSuite.addTest() and
TestSuite.addTests() concerning a lack of input
checking on the input test case(s)/suite(s).

3) Fix a bug in both TestLoader.loadTestsFromName() and
TestLoader.loadTestsFromNames() that had ValueError
being raised instead of TypeError. The problem occured
when the given name resolved to a callable and the
callable returned something of the wrong type.

4) When a name resolves to a method on a TestCase
subclass, TestLoader.loadTestsFromName() did not return
a suite as promised.

5) TestLoader.loadTestsFromName() would raise a
ValueError (rather than a TypeError) if a name resolved
to an invalid object. This has been fixed so that a
TypeError is raised.

6) TestResult.shouldStop was being initialised to 0 in
TestResult.__init__. Since this attribute is always
used in a boolean context, it's better to use the False

Collin Winter

More information about the Python-Dev mailing list