[Python-checkins] r54208 - python/branches/release25-maint/Lib/unittest.py

Georg Brandl g.brandl at gmx.net
Thu Mar 8 19:37:31 CET 2007


Jim Jewett schrieb:
> On 3/8/07, Georg Brandl <g.brandl at gmx.net> wrote:
>> Neal Norwitz schrieb:
>> > I'm not sure it's the best thing to backport this. I agree with the
>> > change, but worry that people writing bad unit tests will suddenly
>> > have it break. They might have the proper signature, even if they
>> > don't inherit from the right classes.
>>> + if (isinstance(test, (type, types.ClassType)) and
>> + issubclass(test, (TestCase, TestSuite))):
>> + raise TypeError("TestCases and TestSuites must be instantiated
>> "
>> + "before passing them to addTest()")
>>> does allow for tests that don't inherit from TestCase/Suite. It only checks
>> if the test is a TestCase, which is the common case, whether is
>> instantiated.
>> When trying to emulate prototype-based OO (like javascript), it is
> common to have classes that are intended to be singletons; sometimes
> it isn't clear what is a class method and what is an instance method
> of the single instance.
>> It is possible to create a class that itself has the right signature.
> I make no claims about sanity, but it is possible, so it is a concern
> in bugfix releases.
>> Of course, it is also possible to create your own test runner, which
> might not even insist on callability.
>> That said, it may well be that no one has done this, and that someone
> is going along with untested code because the checks aren't there ...
> so I'm not sure what to do. A what's new entry might be enough.
> Something along the line of:
>> """
> unittest now verifies more of its assumptions. If your tests start to
> fail with 2.5.1, it *might* be a problem with the tests themselves --
> and you should verify that they were ever run.
> """

Agreed. I added a NEWS item.
Georg


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /