Adding methods from one class to another, dynamically

Steve Holden steve at holdenweb.com
Tue Feb 2 07:06:32 CET 2010


Oltmans wrote:
> On Feb 2, 2:14 am, Steve Holden <st... at holdenweb.com> wrote:
>> Should not tee be subclassing test, not unittest.TestCase?
>>
> 
> Thank you, Steve. This worked, but I've not clue why? Can you please
> enlighten me why sub-classing 'test' made it happen? Please. Thanks
> again.

unittest.TestCase doesn't have any test* methods (methods whose names
begin with "test"). So neither do your subclasses.

When you subclass test, however, test has everything that
unittest.TestCase does (because it subclasses unittest.TestCase) and it
also has three test* methods. So your subclass of test also has those
three methods as well.

regards
 Steve
-- 
Steve Holden           +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC                 http://www.holdenweb.com/
UPCOMING EVENTS:        http://holdenweb.eventbrite.com/




More information about the Python-list mailing list