Re: Adding methods from one class to another, dynamically

2010-02-01 Thread Steve Holden
Oltmans wrote: > On Feb 2, 2:14 am, Steve Holden 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

Re: Adding methods from one class to another, dynamically

2010-02-01 Thread Oltmans
On Feb 2, 2:14 am, Steve Holden 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. > regards >  Steve > -- > Steve Holden          

Re: Adding methods from one class to another, dynamically

2010-02-01 Thread Michele Simionato
Wanting the same methods to be attached to different classes often is a code smell (perhaps it is not your case and then use setattr as others said). Perhaps you can just leave such methods outside any class. I would suggest you to use a testing framework not based on inheritance (i.e. use nose or

Re: Adding methods from one class to another, dynamically

2010-02-01 Thread Steve Holden
Oltmans wrote: > Thank you for your help, Chris. Looks like I can now attach methods to > class 'tee'. However, after attaching methods to 'tee' when I try to > run them using suite.run() I don't see any of the methods running, I'm > sorry but I've no clue what's failing this. Any insights will be

Re: Adding methods from one class to another, dynamically

2010-02-01 Thread Oltmans
Thank you for your help, Chris. Looks like I can now attach methods to class 'tee'. However, after attaching methods to 'tee' when I try to run them using suite.run() I don't see any of the methods running, I'm sorry but I've no clue what's failing this. Any insights will be highly appreciated. Her

Re: Adding methods from one class to another, dynamically

2010-02-01 Thread Gerald Britton
Or you could just do a mixin: tee.__class__.__bases__ = (test,) + tee.__class__.__bases__ On Mon, Feb 1, 2010 at 3:25 PM, Chris Rebert wrote: > On Mon, Feb 1, 2010 at 12:06 PM, Oltmans wrote: >> Hello Python gurus, >> >> I'm quite new when it comes to Python so I will appreciate any help. >>

Re: Adding methods from one class to another, dynamically

2010-02-01 Thread Carl Banks
On Feb 1, 12:06 pm, Oltmans wrote: > Hello Python gurus, > > I'm quite new when it comes to Python so I will appreciate any help. > Here is what I'm trying to do. I've two classes like below > > import new > import unittest > > class test(unittest.TestCase): >     def test_first(self): >         p

Re: Adding methods from one class to another, dynamically

2010-02-01 Thread Chris Rebert
On Mon, Feb 1, 2010 at 12:06 PM, Oltmans wrote: > Hello Python gurus, > > I'm quite new when it comes to Python so I will appreciate any help. > Here is what I'm trying to do. I've two classes like below > > import new > import unittest > > class test(unittest.TestCase): >    def test_first(self):