subclassing unittest.TestCase?

Fernando Perez fperez528 at yahoo.com
Sat Jun 14 00:26:43 CEST 2003


Chris Curvey wrote:

> Hi all,
> 
> I'm trying to subclass unittest.TestCase and add to the constructor.
> But whenever I try to run my tests, I get
> 
> ValueError: no such test method in HtmlTestCase.HtmlTestCase: runTest
> 
> there must be something simple that I'm missing.  The subclass looks like:
> 
> class HtmlTestCase(unittest.TestCase):
>      def __init__(self):
>           unittest.TestCase.__init__(self)
> # create a random string to use as the test identifier
> self.testId = random.randint(1,10000000)
> self.tags = []
> 
> Any ideas?

you're not passing the arguments through:

class HtmlTestCase(unittest.TestCase):
     def __init__(self,*args):
          unittest.TestCase.__init__(self,*args)
         # create a random string to use as the test identifier
         self.testId = random.randint(1,10000000)
         self.tags = []

best,

f




More information about the Python-list mailing list