471,353 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,353 software developers and data experts.

Unittest testloader and hierarchy of TestSuites

Hi,

I have a module with several test case classes which each have
several test methods:

class Foo(unittest.TestCase):
def testMethod1(self):
def testMethod2(self):

class Bar(unittest.TestCase):
def testMethod3(self):
def testMethod4(self):

When the test suite is composed each of these methods will be
wrapped into a separate TestCase object (=one object per method).
Without knowing the details of the original unit test framework I
would then expect all of them to be wrapped into single TestSuite
instance. The resulting hierarchy would be like:

TestSuite (representing the module)
TestCase (representing testMethod1)
TestCase (representing testMethod2)
TestCase (representing testMethod3)
TestCase (representing testMethod4)

However the TestLoader in unittest.py seems to build following
hierarchy:

TestSuite
TestSuite
TestCase (representing testMethod1)
TestCase (representing testMethod2)
TestSuite
TestCase (representing testMethod3)
TestCase (representing testMethod4)

Of course this still works since TestSuite is implemented to
make recursive calls into nested suites and TestSuite itself
doesn't actually do anything visible to the user.

My question is what would be the "correct" way to compose these
objects into TestSuite according to the unit test framework?

Best regards,
Tero

Jul 18 '05 #1
0 1190

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Paul Moore | last post: by
reply views Thread by Edward Diener | last post: by
reply views Thread by Remy Blank | last post: by
41 posts views Thread by Roy Smith | last post: by
7 posts views Thread by Jorgen Grahn | last post: by
reply views Thread by Chris Fonnesbeck | last post: by
2 posts views Thread by Collin Winter | last post: by
reply views Thread by =?ISO-8859-1?Q?Israel_Fern=E1ndez_Cabrera?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.