Is this the correct way to implement TestSuite?

Lol McBride newspost at lolmc.com
Wed Mar 24 14:07:34 EST 2004


Hi all,
I've been using unittest for a while now but only creating test cases for
individual modules of an application e.g class foo() has a reciprocal
module called class fooTestCase() class bar() has a reciprocal module
called class barTestCase()

Now my app has quite a few modules and I want to run a single test that
calls all of the xxxTestCase() modules and therefore runs all of the tests
I have created so far.Looking at the docs for unittest I see a section
showing the following code which seems to fit what I want:

       suite1 = module1.TheTestSuite()
       suite2 = module2.TheTestSuite()
       alltests = unittest.TestSuite((suite1, suite2))

However as I'm somewhat slow on the uptake for some things I'm unsure how
to create the module to contain the code above.Below is what I think is
how to do it and I would appreciate it if someone could let me know if
this is correct or where I have gone wrong.

import unittest
import os
import sys
sys.path.append('../..')
sys.path.insert(0,os.pardir)
import fooTestCase
import barTestCase

class allTests(unittest.TestCase):

    def makeSuites(self):
       suite1 = module1.TheTestSuite()
       suite2 = module2.TheTestSuite()
       alltests = unittest.TestSuite((suite1, suite2))
       

-- 
It's action,reaction - random interaction.
So who's afraid of a little abstraction?Can't get no satisfaction from the facts?
you better run home boy,a facts a fact from Rome to Nome.
Copyright Peart,Lifeson and Lee



More information about the Python-list mailing list